home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / libbasic / summary.txt < prev    next >
Text File  |  1992-09-16  |  50KB  |  1,826 lines

  1. ABS( n )
  2.  
  3. Description:
  4.  
  5.   This function returns  | n |  (the absolute value of n).
  6.  
  7. Usage:
  8.  
  9.   print abs( -5)                   produces:  5
  10.  
  11.   print abs( 6 - 13 )            produces: 7
  12.  
  13.  
  14.  
  15. ASC( n$ )
  16.  
  17. Description:
  18.  
  19.   This function returns the ASCII value of the first character of string n$.
  20.  
  21. Usage:
  22.  
  23.   print asc( "A" )              produces:  65
  24.  
  25.   let name$ = "Tim"
  26.   firstLetter = asc(name$)
  27.   print firstLetter             produces:  84
  28.  
  29.   print asc( "" )               produces:  0
  30.  
  31.  
  32.  
  33. ACS( n )
  34.  
  35. Description:
  36.  
  37.   Returns the arc-cosine of the number n.
  38.  
  39. Usage:
  40.  
  41.   .
  42.   .
  43.   for c = 1 to 45
  44.     print "The arc-cosine of "; c; " is "; acs(c)
  45.   next c
  46.   .
  47.   .
  48.  
  49. Note:
  50.  
  51.   See also COS( )
  52.  
  53.  
  54.  
  55. ASN( n )
  56.  
  57. Description:
  58.  
  59.   Returns the arcsine of the number n.
  60.  
  61. Usage:
  62.  
  63.   .
  64.   .
  65.   for c = 1 to 45
  66.     print "The arcsine of "; c; " is "; asn(c)
  67.   next c
  68.   .
  69.   .
  70.  
  71. Note:
  72.  
  73.   See also SIN( )
  74.  
  75.  
  76.  
  77. ATN( n )
  78.  
  79. Description:
  80.  
  81.   Returns the arc-tangent of the number n.
  82.  
  83. Usage:
  84.  
  85.   .
  86.   .
  87.   for c = 1 to 45
  88.     print "The arctangent of "; c; " is "; atn(c)
  89.   next c
  90.   .
  91.   .
  92.  
  93. Note:
  94.  
  95.   See also TAN( )
  96.  
  97.  
  98.  
  99. BEEP
  100.  
  101. Description:
  102.  
  103.   This command simply rings the system bell, as in CTRL-G
  104.  
  105. Usage:
  106.  
  107.   .
  108.   .
  109. [loop]
  110.   input "Give me a number between 1 and 10?"; number
  111.   if number < 1 or number > 10 then beep : print "Out of range!" : goto [loop]
  112.   print "The square of "; number; " is "; number ^ 2
  113.   .
  114.   .
  115.  
  116.  
  117.  
  118.  
  119. BMPBUTTON #handle, filespec, return, corner, posx, posy
  120.  
  121. Description:
  122.  
  123.   This statement lets you add bitmapped buttons to windows that you open.  The
  124.   main program window cannot have buttons added, but any window that you
  125.   create via the OPEN command can have as many buttons as you want.  
  126.  
  127. Usage:
  128.  
  129.   Before you actually OPEN the window, each bitmapped  button must be
  130.   declared with a BMPBUTTON statement.  Here is a brief description for
  131.   each parameter as listed above:
  132.  
  133. #handle - You must use the same handle that will be used for the window that
  134.      the button will belong to.
  135.  
  136. filespec   - The full pathname of the *.bmp file containing the bitmap for the
  137.       button you are creating.  The button will be the same size as the
  138.       bitmap.
  139.  
  140. return  - Again, use only one word and do not bound it with quotes or use a
  141.       string variable.  If return is set to a valid branch label, then when
  142.       the button is pressed, execution will restart there (just as with
  143.       GOTO or GOSUB), but if return is not a valid branch label, then the 
  144.       value of return is used as input to a specified variable (as in 
  145.       input a$).
  146.  
  147. corner  - UL, UR, LL, or LR specifies which corner of the window to anchor
  148.       the button to.  For example, if LR is used, then the button will 
  149.       appear in the lower right corner.  UL = upper left, UR = upper 
  150.       right, LL = lower left, and LR = lower right
  151.  
  152. posx, posy - These two parameters determine how to place the button relative to
  153.       the corner it has been anchored to.  For example if corner is LR, 
  154.       posx is 5, and posy is 5, then the button will be 5 pixels up and 
  155.       left of the lower right corner.  Another way to use posx & posy is
  156.       to use values less than one.  For example, if corner is UL, posx
  157.       is .9, and posy is .9, then the button will be positioned 9/10th of 
  158.       the distance of the window in both x and y from the upper left
  159.       corner (and thus appear to be anchored to the lower right corner). 
  160.  
  161.   A collection of button *.bmp has been included with Liberty BASIC, including
  162.   blanks.  Windows Paint can be used to edit and make buttons for Liberty BASIC.
  163.  
  164.   Program execution must be halted at an input statement in order for a button
  165.   press to be read and acted upon.
  166.  
  167.  
  168.   See also: BUTTON, MENU
  169.  
  170.  
  171.  
  172. BUTTON #handle, label, return, corner, posx, posy
  173.  
  174. Description:
  175.  
  176.   This statement lets you add buttons to windows that you open.  The main 
  177.   program window cannot have buttons added, but any window that you create 
  178.   via the OPEN command can have as many buttons as you want.
  179.  
  180. Usage:
  181.  
  182.   Before you actually OPEN the window, each button must be declared with a 
  183.   BUTTON statement.  Here is a brief description for each parameter as listed 
  184.   above:
  185.  
  186. #handle - You must use the same handle that will be used for the window that
  187.       the button will belong to.
  188.  
  189. label   - Type the label desired for the button here.  Do not bound the word
  190.       with quotes, and do not use a string variable.
  191.  
  192. return  - Again, use only one word and do not bound it with quotes or use a
  193.       string variable.  If return is set to a valid branch label, then when
  194.       the button is pressed, execution will restart there (just as with
  195.       GOTO or GOSUB), but if return is not a valid branch label, then the 
  196.       value of return is used as input to a specified variable (as in 
  197.       input a$).
  198.  
  199. corner  - UL, UR, LL, or LR specifies which corner of the window to anchor
  200.       the button to.  For example, if LR is used, then the button will 
  201.       appear in the lower right corner.  UL = upper left, UR = upper 
  202.       right, LL = lower left, and LR = lower right
  203.  
  204. posx, posy - These two parameters determine how to place the button relative to
  205.       the corner it has been anchored to.  For example if corner is LR, 
  206.       posx is 5, and posy is 5, then the button will be 5 pixels up and 
  207.       left of the lower right corner.  Another way to use posx & posy is
  208.       to use values less than one.  For example, if corner is UL, posx
  209.       is .9, and posy is .9, then the button will be positioned 9/10th of 
  210.       the distance of the window in both x and y from the upper left
  211.       corner (and thus appear to be anchored to the lower right corner). 
  212.  
  213.   Program execution must be halted at an input statement in order for a button
  214.   press to be read and acted upon.  See below.
  215.  
  216.  
  217.  
  218. BUTTON Continued
  219.  
  220. Here is a sample program:
  221.  
  222.   ' this button will be labeled Sample and will be located
  223.   ' in the lower right corner.  When it is pressed, program
  224.   ' execution will transfer to [test]
  225.  
  226.   button #graph, Bell, [bell], LR, 5, 5
  227.  
  228.   ' this button will be labeled Example and will be located
  229.   ' in the lower left corner.  When it is pressed, the string
  230.   ' "Example" will be returned.
  231.  
  232.   button #graph, Quit, [quit], LL, 5, 5
  233.  
  234.   ' open a window for graphics
  235.     open "Button Sample" for graphics as #graph
  236.  
  237.   ' print a message in the window
  238.     print #graph, "\\This is a test"
  239.     print #graph, "flush"
  240.  
  241.   ' get button input
  242. [loop]
  243.   input b$   ' stop and wait for a button to be pressed
  244.   if b$ = "Example" then [example]
  245.   goto [loop]
  246.  
  247.  ' the Sample button has been pressed, ring the terminal bell
  248.  ' and close the window
  249. [bell]
  250.   beep
  251.   close #graph
  252.   end
  253.  
  254.  ' The Example button has been pressed, close the window
  255.  ' without ringing the bell
  256. [quit]
  257.   close #graph
  258.   end
  259.  
  260.  
  261.  
  262.   See also:  BMPBUTTON, MENU
  263.  
  264.  
  265.  
  266. CHR$( n )
  267.  
  268. Description:
  269.  
  270.   Returns a one character long string, consisting of the character 
  271.   represented on the ASCII table by the value n (0 - 255).
  272.  
  273. Usage:
  274.  
  275.   ' print each seperate word in text$ on its own line
  276.   text$ = "now is the time for all great men to rise"
  277.   for index = 1 to len(text$)
  278.       c$ = mid$(text$, index, 1)
  279.       ' if c$ is a space, change it to a carraige return
  280.       if c$ = chr$(32) then c$ = chr$(13)
  281.       print c$ ;
  282.   next index                            Produces:
  283.  
  284.                 now
  285.                 is
  286.                 the
  287.                 time
  288.                 for
  289.                 all
  290.                 great
  291.                 men
  292.                 to
  293.                 rise
  294.  
  295.  
  296.  
  297. CLOSE #handle
  298.  
  299. Description:
  300.  
  301.   This command is used to close files and devices.  This is the last step of 
  302.   a file read and/or write, or to close graphic, spreadsheet, or other 
  303.   windows when finished with them.  If when execution of a program is 
  304.   complete there are any files or devices left open, Liberty BASIC will 
  305.   display a dialog informing you that it found it necessary to close the 
  306.   opened files or devices.  This is designed as an aid for you so that you 
  307.   will be able to correct the problem.  If on the other hand you choose to 
  308.   terminate the program early (this is done by closing the program's main 
  309.   window before the program finishes), then Liberty BASIC will close any open 
  310.   files or devices without posting a notice to that effect.
  311.  
  312. Usage:
  313.  
  314.   open "Graphic" for graphics as #gWindow       ' open a graphics window
  315.   print #gWindow, "home"                ' center the pen
  316.   print #gWindow, "down"                ' put the pen down
  317.   for index = 1 to 100                  ' loop 100 times
  318.     print #gWindow, "go "; index                ' move the pen foreward
  319.     print #gWindow, "turn 63"           ' turn 63 degrees
  320.   next index
  321.   input "Press 'Return'."; r$           ' this appears in main window
  322.   close #gWindow                        ' close graphic window
  323.  
  324.  
  325.  
  326. CLS
  327.  
  328. Description:
  329.  
  330.   Clears the main program window of text and sets the cursor back at the 
  331.   upper left hand corner.  Useful  for providing a break to seperate 
  332.   different sections of a program functionally.  Additionally, since the main 
  333.   window doesn't actually discard past information on its own, the CLS 
  334.   command can be used to reclaim memory from your program by forcing the main 
  335.   window to dump old text.
  336.  
  337. Usage:
  338.  
  339.   .
  340.   .
  341.   print "The total is: "; grandTotal
  342.   input "Press 'Return' to continue."; r$
  343.   cls
  344.   print "*** Enter Next Round of Figures ***"
  345.   .
  346.   .
  347.  
  348.  
  349.  
  350. CONFIRM string; responseVar
  351.  
  352. Description:
  353.  
  354.   This statement opens a dialog box displaying the contents of string and 
  355.   presenting two buttons marked 'Yes' and 'No'.  When the selection is made, 
  356.   the string "yes" is returned if 'Yes' is pressed, and the string "no" is 
  357.   returned if 'No' is pressed.  The result is placed in responseVar.
  358.  
  359. Usage:
  360.  
  361. [quit]
  362.  
  363.   ' bring up a confirmation box to be sure that
  364.   ' the user wants to quit
  365.   confirm "Are you sure you want to QUIT?"; answer$
  366.   if answer$ = "no" then [mainLoop]
  367.   end
  368.  
  369.  
  370.  
  371. COS( n )
  372.  
  373. Description:
  374.  
  375.   Returns the cosine of the number n.
  376.  
  377. Usage:
  378.  
  379.   .
  380.   .
  381.   for c = 1 to 45
  382.     print "The cosine of "; c; " is "; cos(c)
  383.   next c
  384.   .
  385.   .
  386.  
  387. Note:
  388.  
  389.   See also SIN( ) and TAN( )
  390.  
  391.  
  392.  
  393. DATE$( )
  394.  
  395. Description:
  396.  
  397.   Instead of adopting MBASIC's date$ variable, we decided to use a function 
  398.   instead, figuring that this might give us additional flexibility later.  
  399.   This function returns the current date in long format.
  400.  
  401. Usage:
  402.  
  403.   print date$( )
  404.  
  405. Produces:
  406.  
  407.   Feb 5, 1991
  408.  
  409. Or you can assign a variable the result:
  410.  
  411.   d$ = date$( )
  412.  
  413.  
  414.  
  415. DIM array(size, size)
  416.  
  417. Description:
  418.  
  419.   DIM sets the maximum size of an array.  Any array can be dimensioned to 
  420.   have as many elements as memory allows.  If an array is not DIMensioned 
  421.   explicitly, then the array will be limited to 10 elements, 0 to 9.  Non 
  422.   DIMensioned double subscript arrays will be limited to 100 elements 0 to 9 
  423.   by 0 to 9.
  424.  
  425. Usage:
  426.  
  427.   print "Please enter 10 names."
  428.   for index = 0 to 9
  429.     input names$ : name$(index) = name$
  430.   next index
  431.  
  432.   The FOR . . . NEXT loop in this example is limited to a maximum value of 9 
  433.   because the array names$( ) is not dimensioned, and therefore is limited to 
  434.   10 elements.  To remedy this problem, we can add a DIM statement, like so:
  435.  
  436.   dim names$(20)
  437.   print "Please enter 20 names."
  438.   for index = 0 to 19
  439.     input names$ : names$(index) = name$
  440.   next index
  441.  
  442. Double subscripted arrays can store information more flexibly, like so:
  443.  
  444.   dim customerInfo$(10, 5)
  445.   print "Please enter information for 10 customers."
  446.   for index = 0 to 9
  447.     input "Customer name >"; info$ : customerInfo$(index, 0) = info$
  448.     input "Address >"; info$ : customerInfo$(index, 1) = info$
  449.     input "City >"; info$ : customerInfo$(index, 2) = info$
  450.     input "State >"; info$ : customerInfo$(index, 3) = info$
  451.     input "Zip >"; info$ : customerInfo$(index, 4) = info$
  452.   next index
  453.  
  454.  
  455.  
  456. ELSE
  457.  
  458.     See IF . . . THEN . . . ELSE
  459.  
  460.  
  461.  
  462. EOF(#handle)
  463.  
  464. Description:
  465.  
  466.   Used to determine when reading from a sequential file whether the end of 
  467.   the file has been reached.  If so, -1 is returned, otherwise 0 is returned.
  468.  
  469. Usage:
  470.  
  471.   open "testfile" for input as #1
  472.   if eof(#1) < 0 then [skipIt]
  473. [loop]
  474.   input #1, text$
  475.   print text$
  476.   if eof(#1) = 0 then [loop]
  477. [skipIt]
  478.   close #1
  479.  
  480.  
  481.  
  482. END
  483.  
  484. Description:
  485.  
  486.   Used to immediately terminate execution of a program.  If any files or 
  487.   devices are still open (see CLOSE) when execution is terminated, then 
  488.   Liberty BASIC will close them for you and present you with a dialog 
  489.   expressing this fact.  It is good programming practice to close files and 
  490.   devices before terminating execution.
  491.  
  492.   Note:  The STOP statement is functionally identical to END and is 
  493.   interchangable
  494.  
  495. Usage:
  496.  
  497.   .
  498.   .
  499.   print "Preliminary Tests Complete."
  500. [askAgain]
  501.   input "Would you like to continue (Y/N) ?"; yesOrNo$
  502.   yesOrNo$ = left$(yesOrNo$, 1)
  503.   if yesOrNo$ = "y" or yesOrNo$ = "Y" then [continueA]
  504.   ifYesOrNo$ = 'n" or yesOrNo$ = "N" then end
  505.   print "Please answer Y or N."
  506.   goto [askAgain]
  507. [continueA]
  508.   .
  509.   .
  510.  
  511.  
  512.  
  513. EXP( n )
  514.  
  515. Description:
  516.  
  517.   This function returns e ^ n,   e being 2.7182818 . . .
  518.  
  519. Usage:
  520.  
  521.   print exp( 5 )              produces:  148.41315
  522.  
  523.  
  524.  
  525. FIELD #handle, # as varName, # as varName, . . . 
  526.  
  527. Description:
  528.  
  529.   FIELD is used with an OPEN "filename.ext" for random as #handle
  530.   statement to specify the fields of data in each record of the opened file.  For
  531.   example in this program FIELD sets up 6 fields of data, each with an
  532.   appropriate length, and associates each with a string variable that holds the
  533.   data to be stored in that field:
  534.  
  535.   open "custdata.001" for random as #cust len = 70   ' open a random access file
  536.   field #cust, 20 as name$, 20 as street$, 15 as city$, 2 as state$, 10 as zip$, 3 as age
  537.  
  538. [inputLoop] 
  539.   input "Name >"; name$
  540.   input "Street >"; street$
  541.   input "City >"; city$
  542.   input "State >"; state$
  543.   input "Zip Code >"; zip$
  544.   input "Age >"; age
  545.  
  546.   confirm "Is this entry correct?"; yesNo$   ' ask if the data is entered correctly
  547.   if  yesNo$ = "no" then [inputLoop]
  548.  
  549.   recNumber = recNumber + 1   ' add 1 to the record # and put the record
  550.   put #cust, recNumber
  551.  
  552.   confirm "Enter more records?"; yesNo$   ' ask whether to enter more records
  553.   if yesNo$ = "yes" then [inputLoop]
  554.  
  555.   close #cust   ' end of program, close file
  556.   end
  557.  
  558. Notice that Liberty BASIC permits the use of numeric variables in FIELD
  559. (eg. age), and it allows you to PUT and GET with both string and numeric
  560. variables, automatically, without needing LSET, RSET, MKI$, MKS$, MKD$,
  561. CVI, CVS, & CVD that are required with Microsoft BASICs.
  562.  
  563. Note: See also PUT and GET
  564.  
  565.  
  566.  
  567. FILEDIALOG titleString, templateString, receiverVar$
  568.  
  569. Description:
  570.  
  571.   This command opens a file dialog box.  The titleString is used to
  572.   label the dialog box.  The templateString is used as a filter to
  573.   list only files matching a wildcard, or to place a full suggested
  574.   filename.
  575.  
  576.  The box lets you navigate around the directory structure,
  577.   looking at files that have a specific extension.  You can then select
  578.   one, and the resulting full path specification will be placed into
  579.   receiverVar$, above.
  580.  
  581.   The following example would produce the dialog box below:
  582.  
  583.     filedialog "test it", "*.txt", fileName$
  584.  
  585.  
  586.  
  587. If then summary.txt were selected, and OK clicked, then program
  588. execution would resume after placing the string "c:\liberty\summary.txt"
  589. into fileName$.
  590.  
  591. If on the other hand Cancel were clicked, then an empty string
  592. would be placed into fileName$.  Program execution would then resume.
  593.  
  594. Look at the program grapher1.bas for a practical application of 
  595. this command.
  596.  
  597.  
  598.  
  599. FOR . . . NEXT
  600.  
  601. Description:
  602.  
  603.   The FOR . . . NEXT looping construct provides a way to repeatedly execute 
  604.   code a specific amount of times.  A starting and ending value are specified 
  605.   like so:
  606.  
  607.   for var = 1 to 10
  608.     {BASIC code}
  609.   next var
  610.  
  611.   In this case, the {BASIC code} is executed 10 times, with var being 1 the 
  612.   first time, 2 the second, and on through 10 the tenth time.  Optionally 
  613.   (and usually) var is used in some calculation(s) in the {BASIC code}.  
  614.   For example if the {BASIC code} is  print var ^ 2, then a list of squares 
  615.   for var will be displayed upon execution.
  616.  
  617.   The specified range could just as easily be 2 TO 20, instead of 1 TO 10, 
  618.   but since the loop always counts +1 at a time, the first number must be 
  619.   less than the second.  The way around this limitation is to place STEP n 
  620.   at the end of for FOR statement like so:
  621.  
  622.   for index = 20 to 2 step -1
  623.     {BASIC code}
  624.   next index
  625.  
  626.   This would loop 19 times returning values for index that start with 
  627.   20 and end with 2.  STEP can be used with both positive and and negative 
  628.   numbers and it is not limited to integer values.  For example:
  629.  
  630.   for x = 0 to 1 step .01
  631.     print "The sine of "; x; " is "; sin(x)
  632.   next x
  633.  
  634.  
  635. Note:
  636.  
  637.   It is not recommended to pass control of a program out of a
  638.   FOR . . . NEXT loop using GOTO (GOSUB is acceptable).
  639.   Liberty BASIC may behave unpredictably.  For example:
  640.  
  641.   for index = 1 to 10
  642.     print "Enter Customer # "; index
  643.     input customer$
  644.     if customer$ = "" then [quitEntry]   ' <- it isn't allowed to cut out of a for ... next loop like this
  645.     cust$(index) = customer$
  646.   next index
  647.   [quitEntry]
  648.  
  649.    . . . is not allowed!  Rather use while ... wend:
  650.  
  651.   index = 1
  652.   while customer$ <> "" and index <= 10
  653.     print "Enter Customer # "; index
  654.     input customer$
  655.     cust$(index) = customer$
  656.     index = index + 1
  657.   wend
  658.  
  659.  
  660.  
  661. GET #handle, recordNumber
  662.  
  663. Description:
  664.  
  665.   GET is used after a random access file is opened to get a record of information
  666.   (see FIELD) out of the file from a specified position.  For example:
  667.  
  668.  
  669.   open "custdata.001" for random as #cust len = 70   ' open random access file
  670.   field #cust, 20 as name$, 20 as street$, 15 as city$, 2 as state$, 10 as zip$, 3 as age
  671.  
  672.   ' get the data from record 1
  673.   get #cust, 1
  674.  
  675.   print name$
  676.   print street$
  677.   print city$
  678.   print state$
  679.   print zip$
  680.   print age
  681.  
  682.   close #cust
  683.   end
  684.  
  685.  
  686. Note:  See also PUT, FIELD
  687.  
  688.  
  689.  
  690. GETTRIM #handle, recordNumber
  691.  
  692. Description:
  693.  
  694.   The GETTRIM command is exactly like the GET command, but when data is
  695.   retrieved, all leading and trailing blank space is removed from all data fields
  696.   before being committed to variables.
  697.  
  698.  
  699.  
  700. GOSUB label
  701.  
  702. Description:
  703.  
  704.   GOSUB causes execution to proceed to the program code following the label
  705.   if it exists,  using the form 'GOSUB label'.  The label can be either a traditional
  706.   line number or a branch label in the     format [???????] where the ?'s can be any
  707.   upper/lowercase letter combination.  Spaces and numbers are not allowed.
  708.  
  709. Here are some valid branch labels:  [mainMenu]  [enterLimits]  [repeatHere]
  710. Here are some invalid branch labels:  [enter limits]  mainMenu  [1moreTime]
  711.  
  712.   After execution is transferred to the point of the branch label, then each 
  713.   statement will be executed in normal fashion until a RETURN is encountered.  
  714.   When this happens, execution is transferred back to the statement 
  715.   immediately after the GOSUB.  The section of code between a GOSUB and its 
  716.   RETURN is known as a 'subroutine.'  One purpose of a subroutine is to save 
  717.   memory by having only one copy of code that is used many times throughout a 
  718.   program.
  719.  
  720. Usage:
  721.  
  722.   .
  723.   .
  724.   print "Do you want to continue?"
  725.   gosub [yesOrNo]
  726.   if answer$ = "N" then [quit]
  727.   print "Would you like to repeat the last sequence?"
  728.   gosub [yesOrNo]
  729.   if answer$ = "Y" then [repeat]
  730.   goto [generateNew]
  731.  
  732. [yesOrNo]
  733.   input answer$
  734.   answer$ = left$(answer$, 1)
  735.   if answer$ = "y" then answer$ = "Y"
  736.   if answer$ = "n" then answer$ = "N"
  737.   if answer$ = "Y" or answer$ = "N" then return
  738.   print "Please answer Y or N."
  739.   goto [yesOrNo]
  740.   .
  741.   .
  742.  
  743.   You can see how using GOSUB [yesOrNo] in this case saves many lines of code 
  744.   in this example.  The subroutine [yesOrNo] could easily be used many other 
  745.   times in such a hypothetical program, saving memory and reducing typing 
  746.   time and effort.  This reduces errors and increases productivity.  See also 
  747.   GOTO
  748.  
  749.  
  750.  
  751. GOTO label
  752.  
  753. Description:
  754.  
  755.   GOTO causes Liberty BASIC to proceed to the program code following the
  756.   label if one exists,  using the form 'GOTO label'.  The label can be either a 
  757.   traditional line number or a branch label in the format [???????] where the 
  758.   ?'s can be any upper/lowercase letter combination.  Spaces and digits are 
  759.   not allowed.
  760.  
  761. Here are some valid branch labels:  [mainMenu]  [enterLimits]  [repeatHere]
  762. Here are some invalid branch labels:  [enter limits]  mainMenu  [1moreTime]
  763.  
  764. Usage:
  765.  
  766.   .
  767.   .
  768. [repeat]
  769.   .
  770.   .
  771. [askAgain]
  772.   print "Make your selection (m, r, x)."
  773.   input selection$
  774.   if selection$ = "M" then goto [menu]
  775.   if selection$ = "R" then goto [repeat]
  776.   if selection$ = "X" then goto [exit]
  777.   goto [askAgain]
  778.   .
  779.   .
  780. [menu]
  781.   print "Here is the main menu."
  782.   .
  783.   .
  784. [exit]
  785.   print "Okay, bye."
  786.   end
  787.  
  788. Notes:
  789.  
  790.   In the lines containing IF . . . THEN GOTO, the GOTO is optional.  
  791.   The expression IF . . . THEN [menu]  is just as valid as 
  792.   IF . . . THEN GOTO [menu].  But in the line GOTO [askAgain], the GOTO 
  793.   is required. 
  794.  
  795.   See also GOSUB
  796.  
  797.  
  798.  
  799. IF expression THEN expression(s)
  800.  
  801. Description:
  802.  
  803.   The purpose of IF . . . THEN is to provide a mechanism for your computer 
  804.   software to make decisions based on the data available.  A decision-making 
  805.   mechanism is used in very simple situations and can be used in combinations 
  806.   to engineer solutions to problems of great complexity.
  807.  
  808.   The expression (see above) is a boolean expression (meaning that it 
  809.   evaluates to a true or false condition).  In this expression we place the 
  810.   logic of our decision-making process.  For example, if we are writing a 
  811.   inventory application, and we need to know when any item drops below a 
  812.   certain level in inventory, then our decision-making logic might look like 
  813.   this:
  814.  
  815.   .
  816.   .
  817.   if level <= reorderLevel then expression(s)
  818.   next BASIC program line
  819.   .
  820.   .
  821.  
  822.   The 'level <= reorderLevel' part of the above expression will evaluate to 
  823.   either true or false.  If the result was true, then the expression(s) part 
  824.   of that line (consisting of a branch label or any valid BASIC statements) 
  825.   will be executed.  Otherwise execution will immediately begin at the next 
  826.   BASIC program line.
  827.  
  828.   The following are permitted:
  829.  
  830.   if a < b then [lessThan]      
  831.  
  832.   This causes program execution to begin at branch label [lessThan]
  833.   if a is less than b.
  834.  
  835.   if sample < lowLimit or sample > highLimit then beep : print"Out of range!"
  836.  
  837.   This causes the terminal bell to ring and the message Out of range! to be 
  838.   displayed if sample is less than lowLimit or greater then highLimit.
  839.  
  840.  
  841.  
  842. IF expression THEN expression(s)1 ELSE expression(s)2
  843.  
  844. Description:
  845.  
  846.   This extended form of IF . . . THEN adds expressiveness and simplifies 
  847.   coding of some logical decision-making software.  Here is an example of its 
  848.   usefulness.
  849.  
  850.   Consider:
  851.  
  852. [retry]
  853.   input"Please choose mode, (N)ovice or e(X)pert?"; mode$
  854.   if len(mode$) = 0 then print "Invalid entry! Retry" : goto [retry]
  855.   mode$ = left$(mode$, 1)
  856.   if instr("NnXx", mode$) = 0 then print "Invalid entry! Retry" : goto [retry]
  857.   if instr("Nn", mode$) > 0 then print "Novice mode" : goto [main]
  858.   print "eXpert mode"
  859. [main]
  860.   print "Main Selection Menu"
  861.  
  862.   Look at the two lines before the [main] branch label.  The first of these 
  863.   two lines is required to branch over the next line.  These lines can be 
  864.   shortened to one line as follows:
  865.  
  866.   if instr("Nn",mode$)> 0 then print "Novice mode" else print "eXpert mode"
  867.  
  868.   Some permitted forms are as follows:
  869.  
  870.   if a < b then statement else statement
  871.   if a < b then [label] else statement
  872.   if a < b then statement else [label]
  873.   if a < b then statement : statement else statement
  874.   if a < b then statement else statement : statement
  875.   if a < b then statement : goto [label] else statement
  876.   if a < b then gosub [label1] else gosub [label2]
  877.  
  878.   Any number of variations on these formats are permissible.  The a < b 
  879.   boolean expression is of course only a simple example chosen for convenience.  
  880.   You must replace it with the correct expression to suit your problem.
  881.  
  882.  
  883.  
  884. INPUT  #handle  "string expression";  variableName
  885.  
  886. Description:
  887.  
  888.   This command has three possible forms:
  889.  
  890.   input var             - stop and wait for user to enter data in the program's
  891.           main window and press the 'Return' key, then assign
  892.           the data entered to var.
  893.  
  894.   input "enter data"; var   - display the string "enter data" and then stop
  895.           and wait for user to enter data in the program's main window
  896.           and press 'Return', then assign the data entered to var.
  897.  
  898.   input #name, var    - or -    input #name, var1, var2
  899.  
  900.    - Get the next data item from the open file or device using handle named 
  901.      #handle and assign the data to var.  If no device or file exists that 
  902.      uses the handle named #handle, then return an error.  In the second case, 
  903.      the next two data items are fetched and assigned to var1 and var2.
  904.  
  905. Usage:
  906.  
  907.   'Display a text file
  908.   input "Please type a filename >";  filename$
  909.   open filename$ for input as #text
  910. [loop]
  911.   if eof(#text) <> 0 then [quit]
  912.   input #text, item$
  913.   print item$
  914.   goto [loop]
  915. [quit]
  916.   close #text
  917.   print "Done."
  918.   end
  919.  
  920.  
  921. Note:  In Liberty BASIC release 1.0, INPUT cannot be used to input data 
  922. directly into arrays, only into the simpler variables.
  923.  
  924.   input a$(1)                   - is illegal
  925.   input string$ : a$(1) = string$       - use this instead
  926.  
  927. This shortcoming will be addressed in a future release.  This should not be a 
  928. problem anyway if you will be checking the input for validity before 
  929. ultimately accepting it.
  930.  
  931.  
  932.  
  933. INPUT (continued)
  934.  
  935. Most versions of Microsoft BASIC implement INPUT to automatically place a 
  936. question mark on the display in front of the cursor when the user is prompted 
  937. for information like so:
  938.  
  939.   input "Please enter the upper limit"; limit
  940.  
  941.   produces:
  942.  
  943.     Please enter the upper limit ? |
  944.  
  945. Liberty BASIC permits you the luxury of deciding for yourself whether the 
  946. question mark appears at all.
  947.  
  948.   input "Please enter the upper limit :"; limit
  949.  
  950.   produces:
  951.  
  952.     Please enter the upper limit: |
  953.  
  954.   and:    input limit    produces simply:
  955.  
  956.     ? |
  957.  
  958. In the simple form input limit, the question mark is inserted automatically,  
  959. but if you do specify a prompt, as in the above example, only the contents of 
  960. the prompt are displayed, and nothing more.  If for some reason you wish to 
  961. input without a prompt and without a question mark, then the following will 
  962. achieve the desired effect:
  963.  
  964.   input ""; limit 
  965.  
  966. Additionally, in most Microsoft BASICs, if INPUT expects a numeric value and 
  967. a non numeric or string value is entered, the user will be faced with a 
  968. comment something like 'Redo From Start', and be expected to reenter.  
  969. Liberty BASIC does not automatically do this, but converts the entry to a zero 
  970. value and sets the variable accordingly.  This is not considered a problem but 
  971. rather a language feature, allowing you to decide for yourself how your 
  972. program will respond to the situation.
  973.  
  974. One last note:  In Liberty BASIC input prompt$; limit is also valid. Try:
  975.  
  976.   prompt$ = "Please enter the upper limit:"
  977.   input prompt$; limit
  978.  
  979.  
  980.  
  981. INPUT$(#handle, items)
  982.  
  983. Description:
  984.  
  985.   Permits the retrieval of a specified number of items from an open file or 
  986.   device using #handle.  If #handle does not refer to an open file or device 
  987.   then an error will be reported.
  988.  
  989. Usage:
  990.  
  991.   'read and display a file one character at a time
  992.   open "c:\autoexec.bat" for input as #1
  993. [loop]
  994.     if eof(#1) <> 0 then [quit]
  995.     print input$(#1, 1);
  996.     goto [loop]
  997. [quit]
  998.     close #1
  999.     end
  1000.  
  1001. For most devices (unlike disk files), one item does not refer a single 
  1002. character, but INPUT$( ) may return items more than one character in length.  
  1003. In most cases, use of INPUT #handle, varName works just as well or better for 
  1004. reading devices.
  1005.  
  1006.  
  1007.  
  1008. INSTR(string1, string2, starting)
  1009.  
  1010. Description:
  1011.  
  1012.   This function returns the position of string2 within string1.  If string2 
  1013.   occurs more than once in string 1, then only the position of the leftmost 
  1014.   occurance will be returned.  If starting is included, then the search for 
  1015.   string2 will begin at the position specified by starting.
  1016.  
  1017. Usage:
  1018.  
  1019.   print instr("hello there", "lo")
  1020.  
  1021.   produces:    4
  1022.  
  1023.   print instr("greetings and meetings", "eetin")
  1024.  
  1025.   produces:    3
  1026.  
  1027.   print instr("greetings and meetings", "eetin", 5)
  1028.  
  1029.   produces:    16
  1030.  
  1031. If string2 is not found in string1, or if string2 is not found after starting,
  1032. then INSTR( ) will return 0.
  1033.  
  1034.   print instr("hello", "el", 3)
  1035.  
  1036.   produces:    0
  1037.  
  1038.   and so does:
  1039.  
  1040.   print instr("hello", "bye")
  1041.  
  1042.  
  1043.  
  1044. INT(number)
  1045.  
  1046. Description:
  1047.  
  1048.   This function removes the fractional part of number, leaving only the whole
  1049.   number part behind.
  1050.  
  1051. Usage:
  1052.  
  1053. [retry]
  1054.   input "Enter an integer number>"; i
  1055.   if i<>int(i) then bell: print i; " isn't an integer! Re-enter.": goto [retry]
  1056.  
  1057.  
  1058.  
  1059. LEFT$(string, number)
  1060.  
  1061. Description:
  1062.  
  1063.   This function returns from string the specified number of characters starting
  1064.   from the left.  So if  string is "hello there", and number is 5, then "hello"
  1065.   would be the result.
  1066.  
  1067. Usage:
  1068.  
  1069.  
  1070. [retry]
  1071.   input "Please enter a sentence>"; sentence$
  1072.   if sentence$ = "" then [retry]
  1073.   for i = 1 to len(sentence$)
  1074.     print left$(sentence$, i)
  1075.   next i
  1076.  
  1077. Produces:
  1078.  
  1079.   Please enter a sentence>That's all folks!
  1080.   T
  1081.   Th
  1082.   Tha
  1083.   That
  1084.   That'
  1085.   That's
  1086.   That's_
  1087.   That's a
  1088.   That's al
  1089.   That's all
  1090.   That's all_
  1091.   That's all f
  1092.   That's all fo
  1093.   That's all fol
  1094.   That's all folk
  1095.   That's all folks
  1096.   That's all folks!
  1097.  
  1098. Note:
  1099.  
  1100.   If number is zero or less, then "" (an empty string) will be returned.  If 
  1101.   the number is greater than or equal to the number of characters in string,
  1102.   then string will be returned.
  1103.  
  1104.   See also MID$( ) and RIGHT$( )
  1105.  
  1106.  
  1107.  
  1108. LEN( string )
  1109.  
  1110. Description:
  1111.  
  1112.   This function returns the length in characters of string, which can be any 
  1113.   valid string expression.
  1114.  
  1115. Usage:
  1116.  
  1117.   prompt "What is your name?"; yourName$
  1118.   print "Your name is "; len(yourName$); " letters long"
  1119.  
  1120.  
  1121.  
  1122. LET assignment expression
  1123.  
  1124. Description:
  1125.  
  1126.   LET is an optional prefix for any BASIC assignment expression.  Most do leave
  1127.   the word out of their programs, but some prefer to use it.
  1128.  
  1129. Usage:
  1130.  
  1131.   Either is acceptable:
  1132.  
  1133.   let name$ = "John"    
  1134. or
  1135.   name$ = "John"
  1136.  
  1137.   Or yet again:
  1138.  
  1139.   let c = sqr(a^2 + b^2)
  1140. or
  1141.   c = sqr(a^2 + b^2)
  1142.  
  1143.  
  1144.  
  1145. LOG( n )
  1146.  
  1147. Description:
  1148.  
  1149.   This function returns the natural log of  n.
  1150.  
  1151. Usage:
  1152.  
  1153.   print log( 7 )              produces:  1.9459101
  1154.   
  1155.   
  1156.   
  1157. MENU #handle, title,   text, branchLabel,   text, branchLabel,  |  , . . .
  1158.  
  1159. Description:
  1160.  
  1161.   Adds a pull down menu to the window at #handle.  Title specifies the title of
  1162.   the menu, as seen on the menu bar of the window, and each  text,
  1163.   branchLabel  pair after the title adds a menu item to the menu, and tells
  1164.   Liberty BASIC where to branch to when the menu item is chosen.  The  |
  1165.   character can optionally be placed between menu items, to cause a seperating
  1166.   line to be added between the items with the menu is pulled down.
  1167.  
  1168.   As an example, if you wanted to have a graphics window opened, and then
  1169.   be able to pull down some menus to control color and geometric objects, your
  1170.   opening code might look like this:
  1171.  
  1172.   menu #geo, &Colors, &Red, [setRed], &Green, [setGreen], &Blue, [setBlue]
  1173.   menu #geo, &Shapes, &Rectangle, [asRect], &Triangle, [asCircle], &Line, [asLine]
  1174.   open "Geometric wite-board" for graphics_nsb as #geo
  1175.   input r$  ' stop and wait for a menu item to be chosen
  1176.  
  1177.   Notice that the MENU lines must go before the OPEN statement, and must
  1178.   use the same handle as the window that it will be associated with (#geo in this
  1179.   case).  This is the same with  the BUTTON statement (see BUTTON).  See
  1180.   that execution must be stopped at an input statement for the menu choice to
  1181.   be acted upon.  This is also the same as with BUTTON.
  1182.  
  1183.   Also notice that the & character placed in the title and text items for the menu
  1184.   determines the accelerator placement for each menu.  Try experimenting.
  1185.  
  1186.  
  1187.  
  1188.  
  1189. MID$(string, index, number)
  1190.  
  1191. Description:
  1192.  
  1193.   Permits the extraction of a sequence of characters from string starting at 
  1194.   index.  If number is not specified, then all the characters from index to the
  1195.   end of the string are returned.  If number is specified, then only as many
  1196.   characters as number specifies will be returned, starting from index.
  1197.  
  1198. Usage:
  1199.  
  1200.   print mid$("greeting Earth creature", 10, 5)
  1201.  
  1202. Produces:
  1203.  
  1204.   Earth
  1205.  
  1206. And:
  1207.  
  1208.   string = "The quick brown fox jumped over the lazy dog"
  1209.   for i = 1 to len(string$) step 5
  1210.     print mid$(string$, i, 5)
  1211.   next i
  1212.  
  1213. Produces:
  1214.  
  1215.   The_q
  1216.   uick_
  1217.   brown
  1218.   _fox_
  1219.   jumpe
  1220.   d_ove
  1221.   r_the
  1222.   _lazy
  1223.   _dog
  1224.  
  1225.  
  1226. Note:
  1227.  
  1228.   See also LEFT$( ) and RIGHT$( )
  1229.  
  1230.  
  1231.  
  1232. NEXT var
  1233.  
  1234.     see  FOR . . . NEXT
  1235.  
  1236.  
  1237.  
  1238.  
  1239. NOMAINWIN
  1240.  
  1241. Description:
  1242.  
  1243.   This command instructs Liberty BASIC not to open a main window for the
  1244.   program that includes this statement.  Some simple programs which do not use
  1245.   seperate windows for graphics, spreadsheet, or text may use only the main
  1246.   window.  Other programs may not need the main window to do their thing, and
  1247.   so simply including NOMAINWIN  somewhere in your program source
  1248.   will prevent the window from opening.
  1249.  
  1250.   If NOMAINWIN is used, when all other windows owned by that program
  1251.   are closed, then the program terminates execution automatically.
  1252.  
  1253.   For examples of the usage of NOMAINWIN, examine the included Liberty
  1254.   BASIC programs (buttons1.bas for example).
  1255.  
  1256.  
  1257.  
  1258. NOTICE "string expression"
  1259.  
  1260. Description:
  1261.  
  1262.   This command pops up a dialog box which displays "string expression" and
  1263.   which has a button OK which the user presses after the message is read. 
  1264.   Pressing Enter also closes the dialog box.
  1265.  
  1266.   Two forms are allowed.  If "string expression" has no Cr character (ASCII 13),
  1267.   then the title of the dialog box will be 'Notice' and "string expression" will be
  1268.   the message displayed inside the dialog box.  If "string expression" does have
  1269.   a Cr character, then the part of "string expression" before Cr will be used as
  1270.   the title for the dialog box, and the part of "string expression" after Cr will be
  1271.   displayed as the message inside.
  1272.  
  1273. Usage:
  1274.  
  1275.     notice "Super Stats is Copyright 1992, Mathware"
  1276.  
  1277.  
  1278. Or:
  1279.  
  1280.     notice "Fatal Error!" + chr$(13) + "The entry buffer is full!"
  1281.   
  1282.  
  1283.  
  1284. OPEN string FOR purpose AS #handle {LEN = #}
  1285.  
  1286. Description:
  1287.  
  1288.   This statement has many functions.  It can be used to open disk files, or to
  1289.   open windows of several kinds.
  1290.  
  1291. Using OPEN with Disk files:
  1292.  
  1293.   A typical OPEN used in disk I/O looks like this:
  1294.  
  1295.   OPEN "\autoexec.bat" for input as #read
  1296.  
  1297.   This example illustrates how we would open the autoexec.bat file for reading.  
  1298.   As you can see, string in this case is "\autoexec.bat", purpose is input, and 
  1299.   #handle is read.
  1300.  
  1301.   string - this must be a valid pathname.  If the file does not exist, it will 
  1302.        be created.
  1303.  
  1304.   purpose - must be input, output, or random
  1305.  
  1306.   #handle - use a unique descriptive word, but must start with a #.  
  1307.         This special handle is used to identify the open file in later 
  1308.         program statements
  1309.  
  1310.   LEN = # - this is an optional addition for use only when opening a random
  1311.                 access file.  The # determines how many characters long each
  1312.                 record in the file is.  If this is not specified, the default length is
  1313.                 128 characters.  See FIELD, GET, and PUT.
  1314.  
  1315. Using OPEN with windows:
  1316.  
  1317.   A typical OPEN used in windows looks like this:
  1318.  
  1319.   OPEN "Customer Statistics Chart" for graphics as #csc
  1320.  
  1321.   This example illustrates how we would open a window for graphics.  Once the 
  1322.   window is open, there are a wide range of commands that can be given to it.
  1323.   As you can see, string in this case is "Customer Statistics Chart", which is used
  1324.   as the title of the window, purpose is graphics (open a window for graphics), 
  1325.   and the #handle is #csc (derived from Customer Statistics Chart), which will 
  1326.   be used as an identifier when sending commands to the window.
  1327.  
  1328.   string - can be any valid BASIC string.  used to label the window
  1329.   purpose - there are a several of possibilities here:
  1330.         graphics, spreadsheet, text
  1331.         any of these can end in _fs, _nsbars (or other suffixes)
  1332.   #handle - as above, must be a unique, descriptive word starting with #
  1333.  
  1334.  
  1335. Note:  Any opened file or window must be closed before program execution is 
  1336. finished.  See CLOSE
  1337.  
  1338.  
  1339.  
  1340. PRINT #handle, pression ; expression(s) ;
  1341.  
  1342. Description:
  1343.  
  1344.   This statement is used to send data to the main window, to a disk file, or 
  1345.   to other windows.  A series of expressions can follow PRINT (there does not 
  1346.   need to be any expression at all), each seperated by a semicolon.  Each 
  1347.   expression is displayed in sequence.  If the data is being sent to a disk 
  1348.   file, or to a window, then #handle must be present.
  1349.  
  1350. PRINTing to a the main window:
  1351.   When the expressions are displayed, then the cursor (that blinking vertical 
  1352.   bar | ) will move down to the next line, and the next time information is 
  1353.   sent to the window, it will be placed on the next line down.  If you do not 
  1354.   want the cursor to move immediately to the next line, then add an additional 
  1355.   semicolor to the end of the list of expressions.  This prevents the cursor 
  1356.   from being moved down a line when the expressions are displayed.  The next 
  1357.   time data is displayed, it will be added onto the end of the line of data 
  1358.   displayed previously.
  1359.  
  1360. Usage:                  Produces:
  1361.  
  1362.   print "hello world"           hello world
  1363.  
  1364.   print "hello ";               hello world
  1365.   print "world"
  1366.   
  1367.   age = 23
  1368.   print "Ed is "; age; " years old"     Ed is 23 years old
  1369.  
  1370. When sending to a disk file and in regard to the use of the semicolon at the 
  1371. end of the expression list, the rules are similar (only you don't see it 
  1372. happen on the screen).  When printing to a window, the expressions sent are 
  1373. usually commands to the window (or requests for information from the window).  
  1374. For more information, see chapter ?, Liberty BASIC Graphics.
  1375.  
  1376.  
  1377.  
  1378. PROMPT string; responseVar
  1379.  
  1380. Description:
  1381.  
  1382.   The PROMPT statement opens a dialog box, displays string, and waits for the 
  1383.   user to type a response and press 'Return' (or press the OK or Cancel 
  1384.   button).  The entered information is placed in responseVar.  If Cancel is 
  1385.   pressed, then a string of zero length is returned.  If responseVar is set to 
  1386.   some string value before PROMPT is executed, then that value will become the 
  1387.   'default' or suggested response.  This means that when the dialog is opened, 
  1388.   the contents of responseVar will already be entered as a response for the 
  1389.   user, who then has the option to either type over that 'default' response, or
  1390.   to press 'Return' and accept it.
  1391.  
  1392. Usage:
  1393.  
  1394.   .
  1395.   .
  1396.   response$ = "C:"
  1397.   prompt "Search on which Drive? A:, B:, or C:"; response$
  1398. [testResponse]
  1399.   if response$ = "" then [cancelSearch]
  1400.   if len(response$) = 2 and instr("A:B:C:", response$) > 0 then [search]
  1401.   prompt "Unacceptable response.  Please try again. A:, B:, or C:"; again$
  1402.   goto [testResponse]
  1403.  
  1404. [search]
  1405.   print "Starting search . . . "
  1406.   .
  1407.   .
  1408.  
  1409.  
  1410.  
  1411. PUT #handle, recordNumber
  1412.  
  1413. Description:
  1414.  
  1415. PUT is used after a random access file is opened to place a record of information
  1416. (see FIELD) into the file at a specified position.  For example:
  1417.  
  1418.  
  1419.   open "custdata.001" for random as #cust len = 70   ' open a random access file
  1420.   field #cust, 20 as name$, 20 as street$, 15 as city$, 2 as state$, 10 as zip$, 3 as age
  1421.   
  1422.   ' enter data into customer variables
  1423.   input name$
  1424.   .
  1425.   .
  1426.  
  1427.   ' put the data into record 1
  1428.   put #cust, 1
  1429.  
  1430.   close #cust
  1431.   end
  1432.  
  1433.  
  1434. Note:  See also GET, FIELD
  1435.  
  1436.  
  1437.  
  1438. REM comment
  1439.  
  1440. Description:
  1441.  
  1442.   The REM statement is used to place comments inside of code to clearly 
  1443.   explain the purpose of each section of code.  This is useful to both the 
  1444.   programmer who writes the code or to anyone who might later need to modify 
  1445.   the program.  Use REM statements liberally.  There is a shorthand way of 
  1446.   using REM, which is to use the ' (apostrophe) character in place of the word 
  1447.   REM.  This is cleaner to look at, but use whichever you prefer.  Unlike other 
  1448.   BASIC statements, with REM you cannot add another statement after it on the 
  1449.   same line using a colon ( : ) to seperate the statements.  The rest of the 
  1450.   line becomes part of the REM statement.
  1451.  
  1452. Usage:
  1453.  
  1454.   rem  let's pretend that this is a comment for the next line
  1455.   print "The mean average is "; meanAverage
  1456.  
  1457. Or:
  1458.  
  1459.   ' let's pretend that this is a comment for the next line
  1460.   print "The strength of the quake was "; magnitude
  1461.  
  1462. This doesn't work:
  1463.  
  1464.   rem  thank the user : print "Thank you for using Super Stats!"
  1465.  
  1466.     (even the print statement becomes part of the REM statement)
  1467.  
  1468.  
  1469. Note:
  1470.  
  1471.   When using ' instead of REM at the end of a line, the statement seperator :
  1472. is not required to seperate the statement on that line from its comment.  
  1473.  
  1474. For example:
  1475.  
  1476.   print "Total dollar value: "; dollarValue : rem  print the dollar value
  1477.  
  1478. Can also be stated:
  1479.  
  1480.   print "Total dollar value: "; dollarValue  ' print the dollar value
  1481.  
  1482. Notice that the : is not required in the second form.
  1483.  
  1484.  
  1485.  
  1486. RETURN
  1487.  
  1488.     See  GOSUB
  1489.  
  1490.  
  1491.  
  1492. RIGHT$(string, number)
  1493.  
  1494. Description:
  1495.  
  1496.   Returns a sequence of characters from the right hand side of string using 
  1497.   number to determine how many characters to return.  If  number is 0, 
  1498.   then "" (an empty string) is returned.  If number is greater than or equal to
  1499.   the number of characters in string, then string will itself be returned.
  1500.  
  1501. Usage:
  1502.  
  1503.   print right$("I'm right handed", 12)
  1504.  
  1505. Produces:
  1506.  
  1507.   right handed
  1508.  
  1509. And:
  1510.  
  1511.   print right$("hello world", 50)
  1512.  
  1513. Produces:
  1514.  
  1515.   hello world
  1516.  
  1517. Note:
  1518.  
  1519.   See also LEFT$( ) and MID$( )
  1520.  
  1521.  
  1522.  
  1523. RND(number)
  1524.  
  1525. Description:
  1526.  
  1527.   This function returns a pseudo random number between 0 and 1.  This can be 
  1528.   useful in writing games and some simulations.  The particular formula used 
  1529.   in this release might more accurately be called an arbitrary number generator 
  1530.   (instead of random number generator), since if a distribution curve of the 
  1531.   output of this function were plotted, the results would be quite uneven.  
  1532.   Nevertheless, this function should prove more than adequate (especially for 
  1533.   game play).
  1534.  
  1535.   In MBASIC it makes a difference what the value of parameter number is, but 
  1536.   in Liberty BASIC, it makes no difference.  The function will always return 
  1537.   an arbitrary number between 0 and 1.
  1538.  
  1539. Usage:
  1540.  
  1541.   ' print ten numbers between one and ten
  1542.   for a = 1 to 10
  1543.       print int(rnd(1)*10) + 1
  1544.   next a
  1545.   
  1546.  
  1547.  
  1548. SIN(number)
  1549.  
  1550. Description:
  1551.  
  1552.   This function return the sine of number.
  1553.  
  1554. Usage:
  1555.  
  1556.   .
  1557.   .
  1558.   for t = 1 to 45
  1559.     print "The sine of "; t; " is "; sin(t)
  1560.   next t
  1561.   .
  1562.   .
  1563.  
  1564. Note:
  1565.  
  1566.   See also COS( ) and TAN( )
  1567.  
  1568.  
  1569.  
  1570. STR$(numericExpression)
  1571.  
  1572. Description:
  1573.  
  1574.   This function returns a string expressing the result of  numericExpression.  
  1575.   In MBASIC, this function would always return a string representation of the 
  1576.   expression and it would add a space in front of that string.  For example 
  1577.   in MBASIC:
  1578.  
  1579.   print len(str$(3.14))
  1580.  
  1581.   Would produce the number 5 (a space followed by 3.14 for a total of 5 
  1582.   characters).
  1583.  
  1584.   Liberty BASIC leaves it to you to decide whether you want that space or not.  
  1585.   If you don't want it, then you need not do anything at all, and if you do 
  1586.   want it, then this expression will produce the same result under Liberty 
  1587.   BASIC:
  1588.  
  1589.   print len(" " + str$(3.14))
  1590.  
  1591. Usage:
  1592.  
  1593.   .
  1594.   .
  1595. [kids]
  1596.   ' use str$( ) to validate entry
  1597.   input "How many children do you have?"; qtyKids
  1598.   qtyKids$ = str$(qtyKids)
  1599.   ' if the entry contains a decimal point, then the response is no good
  1600.   if instr(qtyKids$, ".") > 0 then print "Bad response. Reenter." : goto [kids]
  1601.   .
  1602.   .
  1603.  
  1604.  
  1605.  
  1606. TAN(number)
  1607.  
  1608. Description:
  1609.  
  1610.   This function return the tangent of number.
  1611.  
  1612. Usage:
  1613.  
  1614.   .
  1615.   .
  1616.   for t = 1 to 45
  1617.     print "The tangent of "; t; " is "; tan(t)
  1618.   next t
  1619.   .
  1620.   .
  1621.  
  1622. Note:
  1623.  
  1624.   See also SIN( ) and COS( )
  1625.  
  1626.  
  1627.  
  1628. TIME$( )
  1629.  
  1630. Description:
  1631.  
  1632.   This function returns a string representing the current time of the system 
  1633.   clock in 24 hour format.  This function replaces the time$ variable used in 
  1634.   MBASIC.  See also DATE$( ).
  1635.  
  1636. Usage:
  1637.  
  1638.   .
  1639.   .
  1640.   ' display the opening screen
  1641.   print "Main selection screen             Time now: "; time$( )
  1642.   print
  1643.   print "1. Add new record"
  1644.   print "2. Modify existing record"
  1645.   print "3. Delete record"
  1646.   .
  1647.   .
  1648.  
  1649.  
  1650.  
  1651. TRACE number
  1652.  
  1653. Description:
  1654.  
  1655. This statement sets the trace level for its application program.  This is 
  1656. only effective if the program is run using the Debug menu selection 
  1657. (instead of RUN).  If Run is used, then any TRACE statements are ignored by 
  1658. the interpreter.
  1659.  
  1660.  There are three trace levels: 0, 1, and 2.  Here are the effects of these 
  1661.  levels:
  1662.  
  1663.   0 = single step mode or STEP
  1664.   1 = animated trace or WALK
  1665.   2 = full speed no trace or RUN
  1666.  
  1667. When any Liberty BASIC program first starts under Debug mode, the trace
  1668. level is always initially 0.  You can then click on any of the three buttons
  1669. (STEP, WALK, RUN) to determine what mode to continue in.   When a
  1670. TRACE statement is encountered, the trace level is set accordingly, but you
  1671. can recover from this new trace level by clicking again on the desired button.
  1672.  
  1673. If you are having trouble debugging code at a certain spot, then you can add 
  1674. a TRACE statement (usually level 0) just before that location, run in Debug 
  1675. mode and then click on RUN.  When the TRACE statement is reached, then
  1676. the debugger will kick in at that point.
  1677.  
  1678. Usage:
  1679.  
  1680.   .
  1681.   .
  1682.   'Here is the trouble spot
  1683.   trace 0  ' kick down to single step mode
  1684.   for index = 1 to int(100*sin(index))
  1685.     print #graph, "go "; index ; " "; int(100*cos(index))
  1686.   next index
  1687.   .
  1688.   .
  1689.  
  1690.  
  1691.  
  1692. TRIM$(stringExpression)
  1693.  
  1694. Description:
  1695.  
  1696.   This function removes any spaces from the start and end of the string in 
  1697.   stringExpression.  This can be useful for cleaning up data entry among other 
  1698.   things.
  1699.  
  1700.  
  1701. Usage:
  1702.  
  1703.   sentence$ = "  Greetings  "
  1704.   print len(trim$(sentence$))
  1705.  
  1706. Produces:
  1707.  
  1708.   9
  1709.  
  1710.  
  1711.  
  1712. USING(templateString, numericExpression)
  1713.  
  1714. Description:
  1715.  
  1716.   This function formats numericExpression as a string using templateString.  
  1717.   The rules for the format are like those in MBASIC's PRINT USING statement, 
  1718.   but since USING( ) is a function, it can be used as part of a larger BASIC 
  1719.   expression instead of being useful only for output directly.
  1720.  
  1721.  
  1722. Usage:
  1723.  
  1724.   ' print a column of ten justified numbers
  1725.   for a = 1 to 10
  1726.       print using("####.##",  rnd(1)*1000)
  1727.   next a
  1728.  
  1729.  
  1730.  
  1731. VAL(stringExpression)
  1732.  
  1733. Description:
  1734.  
  1735.   This function returns a numeric value for stringExpression is 
  1736.   stringExpression represents a valid numeric value or if it starts out as 
  1737.   one.  If not, then zero is returned.  This function lets your program take 
  1738.   string input from the user and carefully analyze it before turning it into 
  1739.   a numeric value if and when appropriate. 
  1740.  
  1741. Usage:
  1742.  
  1743.   print 2 * val("3.14")         Produces:       6.28
  1744.  
  1745.   print val("hello")            Produces:       0
  1746.  
  1747.   print val("3 blind mice")     Produces:       3
  1748.  
  1749.  
  1750.  
  1751. WHILE expression . . . WEND
  1752.  
  1753. Description:
  1754.  
  1755.   These two statements comprise the start and end of a control loop.  Between 
  1756.   the WHILE and WEND statements place code (optionally) that will be executed 
  1757.   repeatedly while expression evaluates the same.  The code between WHILE and
  1758.   WEND will always execute at least once.  Once execution reaches the WEND
  1759.   statement, for as long as the WHILE expression evaluates to true, then execution
  1760.   will jump back to the WHILE statement.  Expression can be a boolean, 
  1761.   numeric, or string expression.
  1762.  
  1763. Usage:
  1764.  
  1765.   ' loop until midnight (go read a good book)
  1766.   while time$ <> "00:00:00"
  1767.       ' some action performing code might be placed here
  1768.   wend
  1769.  
  1770. Or:
  1771.  
  1772.   ' loop until a valid response is solicited
  1773.   while val(age$) = 0
  1774.      input "How old are you?"; age$
  1775.      if val(age$) = 0 then print "Invalid response.  Try again."
  1776.   wend
  1777.  
  1778. Or:
  1779.  
  1780.   ' generate a list of ten non-consecutive random numbers
  1781.   for count = 1 to 10
  1782.     while random : random = int(rnd(1)*10)+1 : wend
  1783.     print random
  1784.   next count
  1785.  
  1786.  
  1787.  
  1788. WORD$( stringExpression, n )
  1789.  
  1790. Description:
  1791.  
  1792.   This function returns the nth word in stringExpression.  The leading and 
  1793.   trailing spaces are stripped from stringExpression and then it is broken 
  1794.   down into 'words' at the remaining spaces inside.  If n is less than 1 or 
  1795.   greater than the number of words in stringExpression, then "" is returned.
  1796.  
  1797. Usage:
  1798.  
  1799.   print word$("The quick brown fox jumped over the lazy dog", 5)
  1800.  
  1801. Produces:
  1802.  
  1803.   jumped
  1804.  
  1805. And:
  1806.  
  1807.   ' display each word of sentence$ on its own line
  1808.   sentence$ = "and many miles to go before I sleep."
  1809.   token$ = "?"
  1810.   while token$ <> ""
  1811.       index = index + 1
  1812.       tokens$ = word$(sentence$, index)
  1813.       print token$
  1814.   wend
  1815.  
  1816. Produces:
  1817.  
  1818.   and
  1819.   many
  1820.   miles
  1821.   to
  1822.   go
  1823.   before
  1824.   I
  1825.   sleep.
  1826.