home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / w3_prog / lbas09p2.arj / SUMMARY.TXT < prev    next >
Text File  |  1992-05-01  |  51KB  |  1,658 lines

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