home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-14 | 4.8 KB | 170 lines | [TEXT/AxoC] |
- LocalLanguage Basic
- ' -------------------------------------------------
- ' The following 6 programs demonstrate various aspects of
- ' AxoCalculator's Basic programming language.
- '
- ' • To load all 6 programs, choose "Select All" under
- ' the "Edit" menu, then press "enter".
- '
- ' • To run a program, either select it under the
- ' "Calculator" menu, or type its name and press "enter".
- '
- ' • After the programs are loaded, this file does not need
- ' to remain open in order to use them.
- ' --------------------------------------------------
-
- ' ----------------- Global Variables ------------------
- ' The following 1 line section demonstrates how to declare
- ' global arrays. See "The Programming Language" for more
- ' on array declaration.
- ' -----------------------------------------------------
- DIM globalArr(10)
-
-
- ' ------------------- DoCount ------------------------
- ' A very simple program which counts to 10.
- ' It demonstrates how to declare a program, and assign it a
- ' menu string (Count To 10) with a command key option (/1).
- ' ----------------------------------------------------
- program DoCount "Count To 10/4"
- For i = 1 to 10
- write (i)
- next i
- Print ""
- end
-
- ' ---------------- Factorial -----------------------
- ' A slightly more complex program which calculates
- ' all the factorial numbers from 1 to 15.
- ' It uses a multi-parameter "Print" statement.
- ' -------------------------------------------------
- program Fact "Factorial 1 to 10/5"
- f = 1
- For i = 1 to 10
- ' • Calculate the factorial •
- f = f * i
- Print ("Factorial ",i," = ",f)
- Next i
- end
-
-
- ' ------------------ Trigonometry ------------------
- ' This program uses an internal trigonometric function.
- ' -------------------------------------------------
- program Trig "Cos 0 to 90/6"
- ' • Calculate the cosine of angles from 0 to 90 in steps of 10 •
- For i = 0 to 9
- degrees = i * 10
- cosResult = cos (degrees)
- print ("cos ( ",degrees,") = ",cosResult)
- Next i
- end
-
-
- ' ------------ String Variables -----------------
- ' This program shows how to create and initialize
- ' string variables. It shows how to pass them as
- ' arguments to a procedure or function.
- ' ---------------------------------------------
- Sub Print2Strings (aString, bString)
- Print ("1) ", aString)
- Print ("2) ", bString)
- end
-
- program DemoString "String Variable Example/7"
- ' Strings created "on the fly".
- aString = "Anhydrohydroxyprogesterone"
- bString = "synthetic female hormone"
-
- ' The "Concat" function combines 2 or more strings
- cString = concat (aString,": ",bString)
-
- aString = "Trinitrophenylmethylnitramine"
- bString = "a type of explosive."
-
- ' String created procedurally.
- NewString (dString)
- dString = concat (aString,": ",bString)
-
- ' Strings passed as arguments to a subroutine.
- Print2Strings (cString, dString)
- end
-
-
- ' -------------- Test Array Arithmetic ------------
- ' This program initialize the global array, "globalArr", and
- ' creates and initializes a local array, "localArr".
- ' It adds, the two arrays, and outputs the result.
- ' -----------------------------------------------
- program testArr "Array Example/8"
- DIM localArr(10)
-
- ' • Initialize the local and global arrays •
- For i = 1 to 10
- localArr(i) = 100
- globalArr(i) = i
- Next i
-
- ' • Add the two arrays •
- globalArr = globalArr + localArr
- writeArr (globalArr)
- end
-
-
- ' -------------- Sphere Volume and S.A. ----------------
- ' This program demonstrates the "poseDialog" and "Alert"
- ' commands. It uses poseDialog to prompt the user for
- ' a sphere's radius, then calculates the volume and
- ' surface area of the sphere, and returns the results
- ' to the user in an alert dialog.
- ' ----------------------------------------------------
- program sphere "Volume and S.A. of Sphere/9"
- ' • Ask the user for the radius of the sphere •
- poseDialog ("\rCalculate the volume and surface area of a sphere",
- & "Radius of sphere ",radius)
-
- ' • Calculate the surface area and volume •
- theSA = 4 * pi * radius ^ 2
- theVolume = (4 / 3) * pi * radius ^ 3
-
- ' • Send the results to an alert dialog •
- Alert ("The volume and surface area of a \r sphere with radius ",
- & radius," are : \r Volume = ",theVolume,
- & "\r Surface area = ",theSA)
- end
-
-
- ' ------------------- Count Down ----------------------
- ' This program demonstrates the "FlushOutput" and "Beep"
- ' commands. It counts down from 10 to 0 beeping at each
- ' count. A pause is introduces between each count by
- ' performing several hundred exponential calculations.
- ' -----------------------------------------------------
- program CountDown "Lift Off/0"
- Print ("Prepare for count down.")
- FlushOutput
- ' • Pause •
- For k = 1 to 50
- a = exp(2.0)
- Next k
- ' • Start the Count down •
- For m = 0 to 10
- j = 10 - m
- if (j = 3) Print ("Ignition.")
- if (j = 0) then
- Print ("Lift Off !!")
- else
- Print (j)
- endif
- FlushOutput
- Beep
- j = j - 1
-
- ' • Slow down the count •
- For k = 1 to 20
- a = exp(2.0)
- Next k
- Next m
- end
-
-