home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lb091.zip / GUIPROG.TXT < prev    next >
Text File  |  1995-09-30  |  53KB  |  1,543 lines

  1. GUI Programming
  2.  
  3. A Simple Example
  4.  
  5. In Liberty BASIC windows are treated like files, and we can refer to anything
  6. in this class as a BASIC device.  To open a window we use the OPEN statement,
  7. and to close the window we use the CLOSE statement.  To control the window
  8. we 'print' to it, just as we would print to a file.  The commands are sent as 
  9. strings to the device.  As a simple example, here we will open a graphics 
  10. window, center a pen (like a Logo turtle), and draw a simple spiral.  We will
  11. then pause by opening a simple dialog.  When you confirm the exit, we will close
  12. the window:
  13.  
  14.     button #graph, Exit, [exit], LR, 5, 5  'window will have a button
  15.     open "Example" for graphics as #graph  'open graphics window
  16.     print #graph, "trapclose [exit]"       'set up close procedure
  17.     print #graph, "up"                     'make sure pen is up
  18.     print #graph, "home"                   'center the pen
  19.     print #graph, "down"                   'make sure pen is down
  20.     for index = 1 to 60                    'draw 60 spiral segments
  21.     print #graph, "go "; index * 2     'go foreward index * 2 units
  22.     print #graph, "turn 118"           'turn 118 degrees
  23.     next index                             'loop back 60 times
  24.     print #graph, "flush"                  'make the image 'stick'
  25.  
  26.   [inputLoop]
  27.     input b$ : goto [inputLoop]            'wait for button press
  28.  
  29.   [exit]
  30.     confirm "Close Window?"; answer$       'dialog to confirm exit
  31.     if answer$ = "no" then [inputLoop]     'if answer$ = "no" loop back
  32.     close #graph
  33.  
  34.   end                                   
  35.  
  36. Using FreeForm
  37.  
  38. Using the information in this book, you could manually write all the code 
  39. you need to create the windows you need for your programs.  This is a lot 
  40. of work, time, and tedium.  FreeForm was created to end this drudgery by 
  41. letting you visually draw your program's windows, and it writes the 
  42. Liberty BASIC source code for you.
  43.  
  44. By selecting the Run menu and picking FreeForm Lite from that menu, 
  45. FreeForm will be loaded.
  46.  
  47. Below we see an example run of FreeForm.  
  48.  
  49. <image was here>
  50.  
  51. The menu items for FreeForm are:
  52.  
  53. - Files         For loading and saving forms
  54. - Control       For inspecting properties, deleting, and moving controls
  55. - Output        For generating Liberty BASIC code from forms
  56. - Window        For changing the form window handle, title, and type
  57. - Options       For setup and configuration
  58. - Menu  For editing the forms menu bar
  59.  
  60. The ten buttons on the left side of the FreeForm window represent different kinds
  61. of controls that can be added to a form.  When a button is clicked on, you are
  62. optionally asked for some information (a button label perhaps), and the control
  63. is added to the window.  Then you can move the control and size it as desired.
  64.  
  65. Make sure to inspect each control (double-click on a control to inspect it) to set
  66. its properties.
  67.  
  68. When you are happy with the layout of the window, pull down the Output menu 
  69. and select Produce Code.  This will open a window and generate Liberty BASIC 
  70. code into that windows.  You can copy this code into your programs.  Selecting 
  71. the menu item Produce Code + Outline produces even more code for you if desired.
  72.  
  73. NOTE: There are some features of Liberty BASIC that are not supported in the 
  74. current release of FreeForm.  Most notably, some window types (see the section 
  75. Window Types in this book for a complete list of supported types).
  76.  
  77. ___________________________________________________________
  78.  
  79. Size and Placement of Windows
  80.  
  81. The size and placement of any window can be easily determined before it is 
  82. opened in Liberty BASIC (except for any window type with a _fs in its descriptor).
  83. If you do choose not to specify the size and placement of the windows that your 
  84. programs open, Liberty BASIC will pick default sizes.  However, for effect it is 
  85. often best that you exercise control over this matter.
  86.  
  87. There are four special variables that you can set to select the size and 
  88. placement of your windows, whether they be text, graphics, or spreadsheet:
  89.  
  90.       UpperLeftX, UpperLeftY, WindowWidth, and WindowHeight
  91.  
  92. Set UpperLeftX and UpperLeftY to the number of pixels from the upper-left corner 
  93. of the screen to position the window.  Often determining the distance from the 
  94. upper-left corner of the screen is not as important as determining the size of the 
  95. window.
  96.  
  97. Set  WindowWidth and WindowHeight to the number of pixels wide and high that 
  98. you want the window to be when you open it.
  99.  
  100. Once you have determined the size and placement of your window, then open it.
  101. Here is an example:
  102.  
  103.  
  104.   [openStatus]
  105.  
  106.       UpperLeftX = 32
  107.       UpperLeftY = 32
  108.       WindowWidth = 190
  109.       WindowHeight = 160
  110.  
  111.       open "Status Window" for spreadsheet as #stats
  112.  
  113.  
  114. This will open a window 32 pixels from the corner of the screen (in OS/2 that's
  115. the lower-left corner of the screen), and with a width of 190 pixels, and a 
  116. height of 160 pixels. 
  117.  
  118. ___________________________________________________________
  119.  
  120. Windows Types
  121.  
  122. Liberty BASIC provides seventeen different kinds of window types, to which you 
  123. can add as many controls as needed (see section Controls - Menus, Buttons, Etc.).  
  124.  
  125. The way that you would specify what kind of window to open would be as follows:
  126.  
  127.     open "Window Title" for type   as #handle
  128.  
  129.   where type  would be one of the seventeen descriptors (below).
  130.  
  131.  
  132. Window types:
  133.  
  134. graphics                open a graphics window
  135. graphics_fs             open a graphics window full screen (size of the screen)
  136. graphics_nsb    open a graphics window w/no scroll bars
  137. graphics_fs_nsb open a graphics window full screen, w/no scroll bars
  138.  
  139. text                    open a text window
  140. text_fs         open a text window full screen
  141. text_nsb                open a text window w/no scroll bars
  142. text_nsb_ins            open a text window w/no scroll bars, with inset editor
  143.  
  144. spreadsheet             open a spreadsheet window
  145.  
  146. window          open a basic window type
  147. window_nf               open a basic window type without a sizing frame
  148.  
  149. dialog                  open a dialog box
  150. dialog_modal    open a modal dialog box
  151. dialog_nf               open a dialog box with no frame
  152. dialog_nf_modal open a modal dialog box with no frame
  153. dialog_fs               open a dialog box the size of the screen
  154. dialog_nf_fs            open a dialog box with no frame the size of the screen
  155.  
  156. Note: A modal window is one which when opened disables the window immediately
  157. underneath it until the modal window is closed.  For an example using modal 
  158. windows, see BASIC file ff12.bas.
  159.  
  160. Graphics Window Commands
  161.  
  162. Most of these commands work only with windows of type graphics.
  163.  
  164. Because graphics can involve many detailed drawing operations, Liberty BASIC 
  165. does not force you to use just one print # statement for each drawing task.  If 
  166. you want to perform several operations you can use a single line for each as 
  167. such:
  168.  
  169.     print #handle, "cls"
  170.     print #handle, "fill black"
  171.     print #handle, "up"
  172.     print #handle, "home"
  173.     print #handle, "down"
  174.     print #handle, "north"
  175.     print #handle, "go 50"
  176.  
  177.   Or if you prefer:
  178.  
  179.     print #handle, "cls ; fill black ; up ; home ; down ; north ; go 50"
  180.  
  181.   will work just as well, and executes slightly faster.
  182.  
  183.  
  184. Here are the commands:
  185.  
  186.   print #handle, "\text"
  187.  
  188.     Display text at the current pen position.  Each additional \ in the
  189.     text will cause a carraige return and line feed.  Take for example,
  190.     print #handle, "\text1\text2" will cause text1 to be printed at the
  191.     pen position, and then text2 will be displayed directly under text1.
  192.  
  193.  
  194.   print #handle, "cls"
  195.  
  196.     Clear the graphics window to white, erasing all drawn elements
  197.  
  198.   print #handle, "fill COLOR"
  199.  
  200.     Fill the window with COLOR.  For a list of accepted colors see
  201.     the color command below.
  202.  
  203.  
  204. print #handle, "up"
  205.  
  206.     Lift the pen up.  All go or goto commands will now only move the
  207.     pen to its new position without drawing.  Any other drawing
  208.     commands will simply be ignored until the pen is put back down.
  209.  
  210.  
  211.   print #handle, "down"
  212.  
  213.     Just the opposite of up.  This command reactivates the drawing
  214.     process.
  215.  
  216.  
  217.   print #handle, "home"
  218.  
  219.     This command centers the pen in the graphics window.
  220.  
  221.  
  222.   print #handle, "color COLOR"
  223.  
  224.     Set the pen's color to be COLOR.
  225.  
  226.     Here is a list of valid colors (in alphabetical order):
  227.  
  228.       black, blue, brown, cyan, darkblue, darkcyan, darkgray,
  229.       darkgreen, darkpink, darkred, green, lightgray, palegray,
  230.       pink, red, white, yellow
  231.  
  232.  
  233.   print #handle, "backcolor COLOR"
  234.  
  235.     This command sets the color used when drawn figures are filled with a
  236.     color.  The same colors are available as with the color command above.
  237.   print #handle, "goto X Y"
  238.  
  239.     Move the pen to position X Y.  Draw if the pen is down.
  240.  
  241.  
  242.   print #handle, "place X Y"
  243.  
  244.     Position the pen at X Y.  Do not draw even if the pen is down.
  245.  
  246.  
  247.   print #handle, "go D"
  248.  
  249.     Go foreward D distance from the current position, and going in the
  250.     current direction.
  251.  
  252.  
  253.   print #handle, "north"
  254.  
  255.     Set the current direction to 270 (north).  Zero degrees points to the
  256.     right (east), 90 points down (south), and 180 points left (west).
  257.  
  258.  
  259.   print #handle, "turn A"
  260.  
  261.     Turn from the current direction using angle A and adding it to the
  262.     current direction.  A can be positive or negative.
  263.  
  264.  
  265.   print #handle, "line X1 Y1 X2 Y2"
  266.  
  267.     Draw a line from point X1 Y1 to point X2 Y2.  If the pen is up, then
  268.     no line will be drawn, but the pen will be positioned at X2 Y2.
  269.  
  270.  
  271.   print #handle, "posxy"
  272.  
  273.     Return the position of the pen in x, y.  Follow this command with:
  274.  
  275.       input #handle, xVar, yVar
  276.  
  277.     which will assign the pen's position to xVar & yVar
  278.  
  279.  
  280.   print #handle, "size S"
  281.  
  282.     Set the size of the pen to S.  The default is 1.  This will affect the
  283.     thickness of lines and figures plotted with most of the commands
  284.     listed in this section.
  285.  
  286.  
  287.   print #handle, "flush"
  288.  
  289.     This ensures that drawn graphics 'stick'.  Make sure to issue this
  290.     command at the end of a drawing sequence to ensure that when the
  291.     window is resized or overlapped and redrawn, its image will be
  292.     retained.  To each group of drawn items that is terminated with flush,
  293.     there is assigned a segment ID number.  See segment below.
  294.  
  295.  
  296.   print #handle, "print"
  297.  
  298.     Send the plotted image to the Windows Print Manager for output.
  299.  
  300.  
  301.   print #handle, "font facename width height"
  302.  
  303.     Set the pen's font to the specified face, width and height.  If an
  304.     exact match cannot be found, then Liberty BASIC will try to find a
  305.     close match, with size being of more prominance than face.
  306.  
  307.  
  308.   print #handle, "circle r"
  309.  
  310.     Draw a circle with radius r at the current pen position.
  311.   print #handle, "circlefilled r"
  312.  
  313.     Draw a circle with radius r, and filled with the color specified using
  314.     the command backcolor (see above).
  315.  
  316.  
  317.   print #handle, "box x y"
  318.  
  319.     Draw a box using the pen position as one corner, and x, y as the
  320.     other corner.
  321.  
  322.  
  323.   print #handle, "boxfilled x y"
  324.  
  325.     Draw a box  using the pen position as one corner, and x, y as the other 
  326.     corner.  Fill the box with the color specified using the command 
  327.     backcolor (see above).
  328.  
  329.  
  330.   print #handle, "ellipse w h"
  331.  
  332.     Draw an ellipse at the pen position of width w and height h.
  333.  
  334.  
  335.   print #handle, "ellipsefilled  w h"
  336.  
  337.     Draw an ellipse at the pen position of width w and height h.  Fill the 
  338.     ellipse with the color specified using the command backcolor (see
  339.     above).
  340.  
  341.  
  342.   print #handle, "pie w h angle1 angle2"
  343.  
  344.     Draw a pie slice inside of an ellipse of width w and height h.  Start the
  345.     pie slice at angle1, and then sweep clockwise angle2 degrees if angle2 is
  346.     positive, or sweep counter-clockwise angle2 degrees if angle2 is 
  347.     negative.
  348.  
  349.  
  350.   print #handle, "piefilled w h angle1 angle2"
  351.  
  352.     Draw a pie slice inside of an ellipse of width w and height h.  Start the 
  353.     slice at angle1, and then sweep clockwise angle2 degrees if angle2 is
  354.     positive, or sweep counter-clockwise angle2 degrees if angle2 is 
  355.     negative.  Fill the pie slice with the color specified using the command
  356.     backcolor (see above).
  357.  
  358.  
  359.   print #handle, "segment"
  360.  
  361.     This causes the window to return the segment ID of the most recently
  362.     flushed drawing segment.  This segment ID can then be retrieved
  363.     with an input #handle, varName and varName will contain the segment
  364.     ID number.  Segment ID numbers are useful for manipulating different
  365.     parts of a drawing.  For an example, see delsegment below.
  366.  
  367.  
  368.   print #handle, "delsegment n"
  369.  
  370.     This causes the drawn segment identified as n to be removed from the
  371.     window's list of drawn items.  Then when the window is redrawn the
  372.     deleted segment will not be included in the redraw.
  373.  
  374.  
  375.   print #handle, "redraw"
  376.  
  377.     This will cause the window to redraw all flushed drawn segments.  Any
  378.     deleted segments will not be redrawn (see delsegment above).  Any
  379.     items drawn since the last flush will not be redrawn either, and will be
  380.     lost.
  381.  
  382.   print #handle, "discard"
  383.  
  384.     This causes all drawn items since the last flush to be discarded, but does 
  385.     not not force an immediate redraw, so the items that have been 
  386.     discarded will still be displayed until a redraw (see above).
  387.  
  388.   print #handle, "drawbmp bmpname x y"
  389.  
  390.     This will draw a bitmap named bmpname (loaded beforehand with the 
  391.     LOADBMP statement, see command reference) at the location x y.
  392.  
  393.  
  394.   print #handle, "rule rulename"
  395.  
  396.     This command specifies whether drawing overwrites (rulename OVER) 
  397.     on the screen or uses the exclusive-OR technique (rulename XOR).
  398.  
  399.  
  400.   print #handle, "trapclose branchLabel"
  401.  
  402.     This will tell Liberty BASIC to continue execution of the program at
  403.     branchLabel if the user double clicks on the system menu box
  404.     or pulls down the system menu and selects close.
  405.  
  406.  
  407.   print #handle, "when event branchLabel"
  408.  
  409.     This tells the window to process mouse events.  These events occur
  410.     when someone clicks, double-clicks, drags, or just moves the mouse
  411.     inside of the graphics window.  This provides a really simple 
  412.     mechanism for controlling flow of a program which uses the graphics
  413.     window.  For an example, see the program draw1.bas.
  414.  
  415.     Sending print #handle, "when leftButtonDown [startDraw]" to any
  416.     graphics window will tell that window to force a goto [startDraw] when
  417.     the mouse points inside of that window and someone press the left 
  418.     mouse button down.
  419.  
  420.     Whenever a mouse event does occur, Liberty BASIC places the x and y
  421.     position of the mouse in the variables MouseX, and MouseY.  The
  422.     values will represent the number of pixels in x and y the mouse was 
  423.     from the upper left corner of the graphic window display pane.
  424.  
  425.     If the expression print #handle, "when event" is used, then trapping
  426.     for that event is discontinued.  It can however be reinstated at any time.
  427.  
  428.  Events that can be trapped:
  429.  
  430.     leftButtonDown              - left mouse button is now down
  431.     leftButton Up               - left  mouse button has been released
  432.     leftButtonMove              - mouse moved while the left button is down
  433.     leftButtonDouble    - left button has been double-clicked
  434.     rightButtonDown     - right mouse button is now down
  435.     rightButton Up              - right  mouse button has been released
  436.     rightButtonMove     - mouse moved while the right button is down
  437.     rightButtonDouble   - right button has been double-clicked
  438.     mouseMove           - mouse moved when no button was down
  439.  
  440. ___________________________________________________________
  441.  
  442.  Text Window Commands
  443.  
  444. The text window works a little differently.  Whatever you print to a text window 
  445. is displayed exactly as sent.  The way to send commands to a text window is to
  446. make the ! character the first character in the string.  It is also important to add
  447. a semicolon to the end of command line (a print #handle line with text window
  448. commands) as in the example below.  If you don't, the print statement will force
  449. a carraige return into the text window each time you print a command to the 
  450. window if you don't.
  451.  
  452. For example:
  453.  
  454.     open "Example" for text as #1       'open a text window
  455.     print #1, "Hello World"             'print Hello World in the window
  456.  
  457. (Listing continued next page...)
  458.  
  459.     print #1, "!font helv 16 37" ;             'change the text window's font
  460.     print #1, "!line 1" ;                       'read line 1
  461.     input #1, string$
  462.     print "The first line of our text window is:"
  463.     print string$
  464.     input "Press 'Return'"; r$
  465.     close #1                                    'close the window
  466.  
  467.  
  468. Here are the text window commands:
  469.  
  470.  
  471.   print #handle, "!cls" ;
  472.  
  473.     Clears the text window of all text.
  474.  
  475.  
  476.   print #handle, "!font faceName width height" ;
  477.  
  478.     Sets the font of the text window to the specified face of width and
  479.     height.  If an exact match cannot be found, then Liberty BASIC will
  480.     try to match as closely as possible, with size figuring more
  481.     prominently than face in the match.
  482.  
  483.  
  484.   print #handle, "!line #" ;
  485.  
  486.     Returns the text at line #.  If # is less than 1 or greater than the
  487.     number of lines the text window contains, then "" (an empty string)
  488.     is returned.  After this command is issued, it must be followed by:
  489.  
  490.     input #handle, string$
  491.  
  492.     which will assign the line's text to string$
  493.  
  494.  
  495.   print #handle, "!lines" ;
  496.  
  497.     Returns the number of lines in the text window.  After this command
  498.     is issued, it must be followed by:
  499.  
  500.     input #handle, countVar
  501.  
  502.     which will assign the line count to countVar
  503.  
  504.  
  505.   print #handle, "!modified?" ;
  506.  
  507.     This returns a string (either "true" or "false") that indicates whether any
  508.     data in the text window has been modified.  This is useful for checking
  509.     to see whether to save the contents of the window before closing it.
  510.  
  511.     To read the result, an input #handle, varName$, must be performed
  512.     after.
  513.  
  514.  
  515.   print #handle, "!selection?" ;
  516.  
  517.     This returns the highlighted text from the window.  To read the result
  518.     an input #handle, varName$ must be performed after.
  519.  
  520.  
  521. print #handle, "!selectall" ;
  522.  
  523.     This causes everything in the text window to be selected.
  524.  
  525.  
  526.   print #handle, "!copy" ;
  527.  
  528.     This causes the currently selected text to be copied to the
  529.     WINDOWS clipboard.
  530.  
  531.  
  532.   print #handle, "!cut" ;
  533.  
  534.     This causes the currently selected text to be cut out of the
  535.     text window and copied to the WINDOWS clipboard.
  536.  
  537.  
  538.   print #handle, "!paste" ;
  539.  
  540.     This causes the text in the WINDOWS clipboard (if there is any) to be
  541.     pasted into the text window at the current cursor position.
  542.  
  543.  
  544.   print #handle, "!origin?" ;
  545.  
  546.     This causes the current text window origin to be returned.  When a text
  547.     window is first opened, the result would be row 1, column 1.  To read 
  548.     the result an input #handle, rowVar, columnVar must be performed
  549.     after.
  550.  
  551.  
  552.   print #handle, "!origin row column" ;
  553.  
  554.     This forces the origin of the window to be row and column.
  555.  
  556.  
  557.   print #handle, "!trapclose branchLabel" ;
  558.  
  559.     This will tell Liberty BASIC to continue execution of the program at
  560.     branchLabel if the user double clicks on the system menu box
  561.     or pulls down the system menu and selects close (see rolodex1.bas).
  562.  
  563. ___________________________________________________________
  564.  
  565. Spreadsheet Window Commands
  566.  
  567. The spreadsheet used in Liberty BASIC is composed of 35 rows of 26 columns
  568. labeled from A to Z.  The upper-left-most cell is A1 and the lower-right-most
  569. cell is Z35.  Each cell can contain one of three types of data:  string, number,
  570. or formula.  To enter one of these three types into any cell, simply move the
  571. selector over the cell on the spreadsheet and begin typing.  When done entering
  572. that cell's contents, press 'Return'.
  573.  
  574.    A string is entered by preceding it with an apostrophe '.  Each cell
  575.    is 11 characters wide so if the string is longer than 11 characters
  576.    it will run into the next cell to its right.
  577.  
  578.    A number is entered by keying its value, either an integer or a floating 
  579.    point number.
  580.  
  581.    A formula is a simple arithmetic expression, using numbers (see above) 
  582.    or cell references.  The result of the formula is displayed  in the cell's 
  583.    position.  Any arithmatic precedence is ignored, so any formula is 
  584.    always evaluated from left to right and parenthesis are not permitted 
  585.    (They aren't needed).  A formula to compute the average of 3 cells might 
  586.    be:   a1 + a2 + a3 / 3
  587.  
  588. The spreadsheet is a very special widget.  Alone it is a very simple but complete
  589. spreadsheet.  But being able to send it commands and data and to be able to read
  590. back data from it via Liberty BASIC makes it a very powerful tool.  For examples,
  591. see grapher.bas and customer.bas.
  592.  
  593. Modes:  The spreadsheet has two modes, manual and indirect.  Manual mode means
  594. that that the operator can freely move about from cell to cell with the arrow keys.
  595. It's also possible to insert formulas in manual mode.  Using indirect mode, the 
  596. user can only move to cells predefined by the controlling application, which also
  597. decides what type of data is contained by each cell, either string or number.
  598.  
  599. Here are the commands:
  600.  
  601.   print #handle, "manual"
  602.  
  603.     The manual mode is the default setting.  This mode permits the
  604.     user to move the cell selector wherever he/she wants and to
  605.     enter any of three data types into any cell: number, string, formula
  606.  
  607.  
  608.   print #handle, "format COLUMN right|fixed|none"
  609.  
  610.     This command lets the application control formatting for an individual
  611.     column (COLUMN can be any letter A .. Z).
  612.  
  613.     right - right justify column
  614.     fixed - assume 2 decimal places for numbers, and right justify also
  615.     none - left justify, default
  616.  
  617.  
  618.   print #handle, "indirect"
  619.  
  620.     The indirect mode is the most useful when using a spreadsheet for
  621.     data entry.  It enables the application to control which cells the
  622.     user has access to, and what kind of information they can contain.
  623.  
  624.  
  625.   print #handle, "cell ADDRESS CONTENTS"
  626.  
  627.     Place CONTENTS into the cell at ADDRESS.  ADDRESS can be any 
  628.     cell address from A1 to Z35.  The letter A to Z must be in uppercase.
  629.     CONTENTS can be any valid string, number or formula (see above).
  630.  
  631.  
  632.   print #handle, "user ADDRESS string|number"
  633.  
  634.     Set aside the cell at ADDRESS (same rules apply as for ADDRESS in
  635.     command cell, above) as a user cell and specify the data it
  636.     contains to be either a string or a number (data entered will be
  637.     automatically converted to correct type).  This command is only
  638.     effective when indirect mode is in effect (see above).
  639.  
  640.  
  641.   print #handle, "select ADDRESS"
  642.  
  643.     Place the selector over the cell at ADDRESS (again, same rules).
  644.     It is important to place the selector over the first cell that
  645.     the user will edit.
  646.  
  647.   print #handle, "result? ADDRESS"
  648.  
  649.     Answer the result or value of the cell at ADDRESS (again, same
  650.     rules).  If ADDRESS is not a valid cell address, then an empty
  651.     string will be returned.  This command must be followed by:
  652.  
  653.     input #handle, var$  (or  input #handle, var  if number expected)
  654.  
  655.     which will leave the desired cell's contents in var$  (or var)
  656.  
  657.  
  658.   print #handle, "formula? ADDRESS"
  659.  
  660.     Answer the formula of the cell at ADDRESS (again, same rules).
  661.     This command must also be followed with:
  662.  
  663.     input #handle, var$  (should always be a string returned)
  664.  
  665.     which will leave the desired cell's formula in var$
  666.  
  667.  
  668.   print #handle, "flush"
  669.  
  670.     This commands forces the spreadsheet to display its most up to
  671.     date results.
  672.  
  673.  
  674.   print #handle, "load pathFileName"
  675.  
  676.     This causes a Liberty BASIC spreadsheet file (which always have
  677.     an .abc extension) named pathFileName to be loaded, replacing
  678.     the current data set.
  679.  
  680.  
  681.   print #handle, "save pathFileName"
  682.  
  683.     This causes spreadsheet data set (which will always have
  684.     an .abc extension) to be saved to disk at pathFileName.
  685.  
  686.   print #handle, "modified?"
  687.  
  688.     This returns a string (either "true" or "false") that indicates whether any
  689.     data in the spreadsheet has been modified.  This is useful for checking
  690.     to see whether to save the contents of the window before closing it.
  691.  
  692.     To read the result, an input #handle, varName$, must be performed
  693.     after.
  694.  
  695.  
  696.   print #handle, "nolabels"
  697.  
  698.     This turns off the row and column labels.
  699.  
  700.  
  701.   print #handle, "labels"
  702.  
  703.     This turns on the row and column labels.
  704.  
  705.  
  706.   print #handle, "trapclose branchLabel"
  707.  
  708.     This will tell Liberty BASIC to continue execution of the program at
  709.     branchLabel if the user double clicks on the system menu box
  710.     or pulls down the system menu and selects close (see rolodex1.bas).
  711.  
  712.  
  713. Controls - Menus, Buttons, Etc.
  714.  
  715. Here are the details for Liberty BASIC commands that add menus, buttons, 
  716. listboxes, and more.
  717.  
  718. Controls and Events
  719.  
  720. When working with controls, you are asked to specify branch labels that are 
  721. associated with user actions made on those controls (clicking, double-clicking, 
  722. selecting, etc.).  For example:
  723.  
  724.   button #main, "Accept", [userAccepts], UL, 10, 10
  725.  
  726. This adds a button to the window (#main) labeled "Accept".  When the program 
  727. is run, and the user clicks on this button, then execution branches to the routine 
  728. at branch label [userAccepts].  This user clicking on the button generates an event.
  729. This is generally how branch label arguments are used in Liberty BASIC windows 
  730. and controls.
  731.  
  732. Liberty BASIC can only respond to events when execution is halted at in INPUT
  733. statement.  Look at this short program:
  734.  
  735.     ' This code demonstrates how to use checkboxes in your
  736.     ' Liberty BASIC programs
  737.  
  738.     'nomainwin
  739.  
  740.     button #1, " &Ok ", [quit], UL, 120, 90
  741.     checkbox #1.cb, "I am a checkbox", [set], [reset], 10, 10, 130, 20
  742.     button #1, " Set ", [set], UL, 10, 50, 40, 25
  743.     button #1, " Reset ", [reset], UL, 60, 50, 50, 25
  744.     textbox #1.text, 10, 90, 100, 24
  745.  
  746.     WindowWidth = 190
  747.     WindowHeight = 160
  748.     open "Checkbox test" for dialog as #1
  749.  
  750. (Listing continued next page...)
  751.  
  752.     print #1, "trapclose [quit]"
  753.  
  754. [waitHere]
  755.     input r$ 
  756.  
  757. [set]
  758.  
  759.     print #1.cb, "set"
  760.     goto [readCb]
  761.  
  762. [reset]
  763.  
  764.   print #1.cb, "reset"
  765.     goto [readCb]
  766.  
  767.   end
  768.  
  769. [readCb]
  770.  
  771.     print #1.cb, "value?"
  772.     input #1.cb, t$
  773.     print #1.text, "I am "; t$
  774.     goto [inputLoop]
  775.  
  776. [quit]
  777.  
  778.     close #1
  779.     end
  780.  
  781. In the above code, Liberty BASIC opens a small window with a checkbox, a 
  782. textbox, and a few buttons.  After that, it stops at an INPUT statement just 
  783. after the branch label [waitHere].  Now if the user clicks on this button or that, 
  784. or in the checkbox, Liberty BASIC can handle the event and go to the appropriate 
  785. branch label.  If a user clicks on a button or causes some other event occur 
  786. before we get back to our INPUT statement, the event is held for processing 
  787. until we again reach that point in the program.
  788.  
  789. Button
  790.  
  791.  Buttons are easily added to Liberty BASIC windows.  The format is simple:
  792.  
  793.     BUTTON #handle, "Label", [branchLabel], corner, distX, distY
  794.     open "A Window!" for graphics as #handle
  795.  
  796. or
  797.  
  798.     BUTTON #handle, "Label", [branchLabel], corner, x, y, width, height
  799.     open "A Window!" for graphics as #handle
  800.  
  801. By placing at least one button statement before  the open statement, we can 
  802. add button(s) to the window.  Let's examine each part of the button statement:
  803.  
  804.     #handle - This needs to be the same as the handle of the window.
  805.  
  806.     "Label" - This is the text displayed on the button.  If only one word is 
  807.            used, then the quotes are optional.
  808.  
  809.     [branchLabel] - This controls what the button does.  When the user 
  810.                 clicks on the button, then program execution continues
  811.                 at [branchLabel] as if the program had encountered a
  812.                 goto [branchLabel] statement.
  813.  
  814.     corner, distX, distY - Corner determines which corner of the window to
  815.                    anchor the button to.  DistX and distY specify how
  816.                    far from that corner in x and y to place the button.
  817.                    The following values are permitted for corner:
  818.  
  819.               UL - Upper Left Corner            UR - Upper Right Corner
  820.               LL - Lower Left Corner            LR - Lower Right Corner
  821.  
  822.     width, height - These are optional.  If you do not specify a width and
  823.               height, then Liberty BASIC will automatically determine
  824.               the size of the button.
  825. Menu
  826.  
  827. Menus are easily added to Liberty BASIC windows.  The format is simple:
  828.  
  829.     MENU #handle, "Title", "Item1", [label1], "Item2", [label2], ...
  830.     open "A Window!" for graphics as #handle
  831.  
  832. By placing at least one menu statement before  the open statement, we can add
  833. menu(s) to the window.  Let's examine each part of the menu statement:
  834.  
  835.     #handle - This needs to be the same as the handle of the window.
  836.  
  837.     "Title" - This is the title displayed on the menu bar.  If only one word is
  838.          used, then the quotes are optional.  By including an ampersand
  839.          and in front of the character desired, you can turn that character
  840.          into a hot-key.  For example, if the title is "&Help", the
  841.          title will appear as Help.
  842.  
  843.     "Item1" and [label1] - This is a line item seen when the menu is pulled
  844.          down.  [label1] is the place where execution continues if this
  845.          menu item is selected by the user.  Just like "Title", "Item1" 
  846.          requires quotes only if there is more than one word.  The
  847.          ampersand character (&) is used to assign a hot-key to the label,
  848.          as in "Title", above.
  849.  
  850.     "Item2" and [label2] - This is a second line item and branch
  851.          label for the menu.  You can have as many is needed, going on
  852.          with "Item3 . . . 4 . . .  5", etc.
  853.  
  854. Adding seperators between menu items to group them is easy.  Simply add a
  855. bar | character between each group of items.  For example:
  856.  
  857.     . . . "&Red", [colorRed], |, "&Size", [changeSize] . . .
  858.  
  859.     adds a line seperator between the Red and Size menu items.
  860.  
  861. Listbox
  862.  
  863. Listboxes in Liberty BASIC can be added to any  windows that are of type
  864. graphics, window, and dialog.  They provide a list selection capability to your
  865. Liberty BASIC programs.  You can control the contents, position, and size of
  866. the listbox, as well as where to transfer execution when an item is selected.
  867. The listbox is loaded with a collection of strings from a specified string array,
  868. and a reload command updates the contents of the listbox from the array when
  869. your program code changes the array.
  870.  
  871. Here is the syntax:
  872.  
  873.   LISTBOX #handle.ext, array$(, [branchLabel], xPos, yPos, wide, high
  874.  
  875.     #handle.ext  -  The #handle part of this item needs to be the same as the
  876.         handle of the window you are adding the listbox to.  The .ext
  877.         part needs to be unique so that you can send commands to the
  878.         listbox and get information from it later.
  879.  
  880.     array$(  -  This is the name of the array (string array only) that contains
  881.         the contents of the listbox.  Be sure to load the array with
  882.         strings before you open the window.  If some time later you
  883.         decide to change the contents of the listbox, simply change
  884.         the contents of the array and send a reload command.
  885.  
  886.     [branchLabel]  -  This is the branch label where execution begins when
  887.         the user selects an item from the listbox by double-clicking.
  888.         Selection by only single clicking does not cause branching
  889.         to occur.
  890.  
  891.     xPos & yPos  -  This is the distance in x and y (in pixels) of the listbox 
  892.                   from the upper-left corner of the window.
  893.  
  894.     wide & high  -  This determines just how wide and high (in pixels) the
  895.                 listbox is.
  896.  
  897. Here are the commands for listbox:
  898.  
  899.   print #handle.ext, "select string"
  900.  
  901.     Select the item the same as string and update the display.
  902.  
  903.  
  904.   print #handle.ext, "selectindex i"
  905.  
  906.     Select the item at index position i and update the display.
  907.  
  908.  
  909.   print #handle.ext, "selection?"
  910.  
  911.     Return the selected item.  This must be followed by the statement:
  912.  
  913.       input #handle.ext, selected$
  914.  
  915.     This will place the selected string into selected$.  If there is no selected
  916.     item, then selected$ will be a string of zero length (a null string).
  917.  
  918.  
  919.   print #handle.ext, "selectionindex?"
  920.  
  921.     Return the index of the selected item.  This must be followed by the 
  922.     statement:
  923.  
  924.       input #handle.ext, index
  925.  
  926.     This will place the index of the selected string into index.  If there is no
  927.     selected item, then index will be set to 0.
  928.  
  929.  
  930.   print #handle.ext, "reload"
  931.  
  932.     This will reload the listbox with the current contents of its array and will
  933.     update the display.
  934.  
  935. print #handle.ext, "font facename width height"
  936.  
  937.     This will set the listbox's font to the font specified.  Windows' font
  938.     selection algorithm is designed to make an approximate match if it     
  939.     cannot figure out exactly which font you want.
  940.  
  941.  
  942.   print #handle.ext, "singleclickselect"
  943.  
  944.     This tells Liberty BASIC to jump to the control's branch label on a 
  945.     single click, instead of the default double click.
  946.  
  947.  
  948.   print #handle.ext, "setfocus"
  949.  
  950.     This will cause the listbox to receive the input focus.  This means that 
  951.     any keypresses will be directed to the listbox.
  952.  
  953.       ' Sample program.  Pick a contact status
  954.  
  955.     options$(0) = "Cold Contact Phone Call"
  956.     options$(1) = "Send Literature"
  957.     options$(2) = "Follow Up Call"
  958.     options$(3) = "Send Promotional"
  959.     options$(4) = "Final Call"
  960.  
  961.     listbox #status.list, options$(, [selectionMade], 5, 35, 250, 90
  962.     button #status, Continue, [selectionMade], UL, 5, 5
  963.     button #status, Cancel, [cancelStatusSelection], UR, 15, 5
  964.     WindowWidth = 270 : WindowHeight = 180
  965.     open "Select a contact status" for window as #status
  966.  
  967.       input r$
  968.  
  969.   [selectionMade]
  970.       print #status.list, "selection?"
  971.       input #status.list, selection$
  972.  
  973. (Listing continues next page...)
  974.  
  975.       notice selection$ + " was chosen"
  976.       close #status
  977.       end
  978.  
  979.   [cancelStatusSelection]
  980.       notice "Status selection cancelled"
  981.       close #status
  982.       end
  983.  
  984. Control of the listbox in the sample program above is provided by printing
  985. commands to the listbox, just as with general window types in Liberty BASIC.
  986. We gave the listbox the handle #status.list, so to find out what was selected,
  987. we use the statement print #status.list, "selection?".  Then we must perform
  988. an input, so we use input #status.list, selection$, and the selected item is
  989. placed into selection$.  If the result is a string of length zero (a null string),
  990. this means that there is no item selected.
  991.  
  992. ___________________________________________________________
  993.  
  994. Combobox
  995.  
  996. Comboboxes are a lot like listboxes, but they are designed to save space.
  997. Instead of showing an entire list of items, they show only the selected one.
  998. If you don't like the selection, then you click on its button (to the right), and
  999. a list appears.  Then you can browse the possible selections, and pick one if
  1000. so desired.  When the selection is made, the new selection is displayed in
  1001. place of the old.  If you don't want to make a new selection, just click on the
  1002. combobox's button again, and the list will disappear.
  1003.  
  1004. Comboboxes in Liberty BASIC can be added to any  windows that are of type
  1005. graphics, window, and dialog.  They provide a list selection capability to
  1006. your Liberty BASIC programs.  You can control the contents, position, and
  1007. size of the combobox, as well as where to transfer execution when an item
  1008. is selected.  The combobox is loaded with a collection of strings from a
  1009. specified string array,  and a reload command updates the contents of the
  1010. combobox from the array when your program code changes the array.
  1011.  
  1012. Here is the syntax:
  1013.  
  1014.   COMBOBOX #handle.ext, array$(, [label], xPos, yPos, wide, high
  1015.  
  1016.     #handle.ext  -  The #handle part of this item needs to be the same as the
  1017.            handle of the window you are adding the listbox to.  The .ext
  1018.            part needs to be unique so that you can send commands to the
  1019.            listbox and get information from it later.
  1020.  
  1021.     array$(  -  This is the name of the array (must be a string array) that 
  1022.            contains the contents of the listbox.  Be sure to load the array 
  1023.         with strings before you open the window.  If some time later 
  1024.         you decide to change the contents of the listbox, simply 
  1025.         change the contents of the array and send a reload command.
  1026.  
  1027.     [label]  -  This is the branch label where execution begins when
  1028.            the user selects an item from the listbox by double-clicking.
  1029.            Selection by only single clicking does not cause branching
  1030.            to occur.
  1031.  
  1032.     xPos & yPos  -  This is the distance in x and y (in pixels) of the listbox 
  1033.            from the upper-left corner of the window.
  1034.  
  1035.     wide & high  -  This determines just how wide and high (in pixels) the
  1036.            listbox is.  Height refers to how far down the selection list
  1037.            reaches when the combobox's button is clicked, not to the
  1038.            size of the initial selection window.
  1039.  
  1040.  
  1041. Here are the commands for combobox:
  1042.  
  1043.  
  1044.   print #handle.ext, "select string"
  1045.  
  1046.     Select the item the same as string and update the display.
  1047.  
  1048.  
  1049.   print #handle.ext, "selectindex i"
  1050.  
  1051.     Select the item at index position i and update the display.
  1052.  
  1053.  
  1054. print #handle.ext, "selection?"
  1055.  
  1056.     Return the selected item.  This must be followed by the statement:
  1057.  
  1058.       input #handle.ext, selected$
  1059.  
  1060.     This will place the selected string into selected$.  If there is no selected
  1061.     item, then selected$ will be a string of zero length (a null string).
  1062.  
  1063.  
  1064.   print #handle.ext, "selectionindex?"
  1065.  
  1066.     Return the index of the selected item.  This must be followed by the 
  1067.     statement:
  1068.  
  1069.       input #handle.ext, index
  1070.  
  1071.     This will place the index of the selected string into index.  If there is no
  1072.     selected item, then index will be set to 0.
  1073.  
  1074.  
  1075.   print #handle.ext, "reload"
  1076.  
  1077.     This will reload the combobox with the current contents of its array and 
  1078.     will update the display.
  1079.  
  1080.  
  1081.   print #handle.ext, "setfocus"
  1082.  
  1083.     This will cause the combobox to receive the input focus.  This means 
  1084.     that any keypresses will be directed to the combobox.
  1085.  
  1086.  
  1087. For a sample program, see the included file dialog3.bas.
  1088.  
  1089. Textbox
  1090.  
  1091. The textbox command lets you add a single item, single line text entry/editor
  1092. box to your windows.  It is useful for generating forms in particular.
  1093.  
  1094. The syntax for textbox is simply:
  1095.  
  1096.   TEXTBOX #handle.ext, xpos, ypos, wide, high
  1097.  
  1098.   #handle.ext  -  The #handle part must be the same as for the window you
  1099.         are adding the textbox to.  The .ext part must be unique for
  1100.         the textbox.
  1101.  
  1102.   xpos & ypos  -  This is the position of the textbox in x and y from the 
  1103.         upper-left corner of the window.
  1104.  
  1105.   wide & high  -  This is the width and height of the textbox in pixels.
  1106.  
  1107.  
  1108. Textbox  understands these commands:
  1109.  
  1110.     print #handle.ext, "a string"
  1111.  
  1112.       This sets the contents of the textbox to be "a string".
  1113.  
  1114.  
  1115.     print #handle.ext, "!contents?"
  1116.  
  1117.       This fetches the contents of the textbox.  This must be followed by:
  1118.  
  1119.     input #handle.ext, varName$
  1120.  
  1121.       The contents will be placed into varName$
  1122.  
  1123. print #handle.ext, "setfocus"
  1124.  
  1125.     This will cause the textbox to receive the input focus.  This means that 
  1126.     any keypresses will be directed to the textbox.
  1127.  
  1128.  
  1129.   ' sample program
  1130.  
  1131.     textbox #name.txt, 20, 10, 260, 25
  1132.     button #name, "OK", [titleGraph], LR, 5, 0
  1133.     WindowWidth = 350 : WindowHeight = 90
  1134.     open "What do you want to name this graph?" for window_nf as #name
  1135.     print #name.txt, "untitled"
  1136.  
  1137. [mainLoop]
  1138.     input wait$
  1139.  
  1140. [titleGraph]
  1141.     print #name.txt, "!contents?"
  1142.     input #name.txt, graphTitle$
  1143.     notice "The title for your graph is: "; graphTitle$
  1144.     close #name
  1145.     end
  1146.  
  1147. ___________________________________________________________
  1148.  
  1149. Texteditor
  1150.  
  1151. Texteditor is a control that like Textbox, but with scroll bars, and with an
  1152. enhanced command set.  The commands are essentially the same as that of a
  1153. window of type text.  NOTICE that all of these commands start with an
  1154. exclamation point, because the control will simple display anything printed
  1155. to it if it doesn't start with an exclamation point.
  1156.  
  1157.  
  1158. Here is the syntax for texteditor:
  1159.  
  1160.   TEXTEDITOR #handle.ext, xpos, ypos, wide, high
  1161.  
  1162.  
  1163. Here are the texteditor commands:
  1164.  
  1165.   print #handle, "!cls" ;
  1166.  
  1167.     Clears the text window of all text.
  1168.  
  1169.  
  1170.   print #handle, "!font faceName width height" ;
  1171.  
  1172.     Sets the font of the text window to the specified face of width and
  1173.     height.  If an exact match cannot be found, then Liberty BASIC will
  1174.     try to match as closely as possible, with size figuring more
  1175.     prominently than face in the match.
  1176.  
  1177.  
  1178.   print #handle, "!line #" ;
  1179.  
  1180.     Returns the text at line #.  If # is less than 1 or greater than the
  1181.     number of lines the text window contains, then "" (an empty string)
  1182.     is returned.  After this command is issued, it must be followed by:
  1183.  
  1184.     input #handle, string$
  1185.  
  1186.     which will assign the line's text to string$
  1187.  
  1188.  
  1189.   print #handle, "!lines" ;
  1190.  
  1191.     Returns the number of lines in the text window.  After this command
  1192.     is issued, it must be followed by:
  1193.  
  1194.     input #handle, countVar
  1195.  
  1196.     which will assign the line count to countVar
  1197.  
  1198.   print #handle, "!modified?" ;
  1199.  
  1200.     This returns a string (either "true" or "false") that indicates whether any
  1201.     data in the text window has been modified.  This is useful for checking
  1202.     to see whether to save the contents of the window before closing it.
  1203.  
  1204.     To read the result, an input #handle, varName$, must be performed
  1205.     after.
  1206.  
  1207.  
  1208.   print #handle, "!selection?" ;
  1209.  
  1210.     This returns the highlighted text from the window.  To read the result
  1211.     an input #handle, varName$ must be performed after.
  1212.  
  1213.  
  1214.   print #handle, "!selectall" ;
  1215.  
  1216.     This causes everything in the text window to be selected.
  1217.  
  1218.  
  1219.   print #handle, "!copy" ;
  1220.  
  1221.     This causes the currently selected text to be copied to the
  1222.     WINDOWS clipboard.
  1223.  
  1224.  
  1225.   print #handle, "!cut" ;
  1226.  
  1227.     This causes the currently selected text to be cut out of the
  1228.     text window and copied to the WINDOWS clipboard.
  1229.  
  1230.  
  1231.   print #handle, "!paste" ;
  1232.  
  1233.     This causes the text in the WINDOWS clipboard (if there is any) to be
  1234.     pasted into the text window at the current cursor position.
  1235.  
  1236.   print #handle, "!origin?" ;
  1237.  
  1238.     This causes the current text window origin to be returned.  When a text
  1239.     window is first opened, the result would be row 1, column 1.  To read
  1240.     the result an input #handle, rowVar, columnVar must be performed 
  1241.     after.
  1242.  
  1243.   print #handle, "!origin row column" ;
  1244.  
  1245.     This forces the origin of the window to be row and column.
  1246.  
  1247. ___________________________________________________________
  1248.  
  1249. Checkbox
  1250.  
  1251. Adds a checkbox control to the window referenced by #handle.  Checkboxes
  1252. have two states, set and reset.  They are useful for getting input of on/off
  1253. type information.
  1254.  
  1255. The syntax of this command is:
  1256.  
  1257.   CHECKBOX #handle.ext, "label", [set], [reset], xOrg, yOrg, wide, high
  1258.  
  1259. Here is a description of the parameters of the CHECKBOX statement:
  1260.  
  1261.     #handle  -  This must be the same as the #handle of the window you are
  1262.         adding the statictext to.  If #handle.ext is used, this
  1263.         allows your program to print commands to the
  1264.         checkbox control.
  1265.  
  1266.     "label"     - This contains the visible text of the checkbox
  1267.  
  1268.     [set]       - This is the branch label to goto when the user sets checkbox
  1269.         by clicking on it.
  1270.  
  1271.     [reset]     - This is the branch label to goto when the user resets the
  1272.         checkbox by clicking on it.
  1273.  
  1274.     xOrg       - This is the x position of the checkbox relative to the upper 
  1275.         left corner of the window it belongs to.
  1276.  
  1277.     yOg - This is the y position of the checkbox relative to the upper 
  1278.         left corner of the window it belongs to.
  1279.  
  1280.     wide        - This is the width of the checkbox control
  1281.  
  1282.     high        - This is the height of the checkbox control
  1283.  
  1284.  
  1285. Checkboxes  understand these commands:
  1286.  
  1287.     print #handle.ext, "set"
  1288.  
  1289.       This sets the checkbox.
  1290.  
  1291.  
  1292.     print #handle.ext, "reset"
  1293.  
  1294.       This resets the checkbox.
  1295.  
  1296.  
  1297.     print #handle.ext, "value?"
  1298.  
  1299.       This returns the status of the checkbox.  Follow this statement with:
  1300.  
  1301.     input #handle.ext, result$
  1302.  
  1303.       The variable result$ will be either "set" or "reset".
  1304.  
  1305.  
  1306.   print #handle.ext, "setfocus"
  1307.  
  1308.     This will cause the combobox to receive the input focus.  This means
  1309.     that any keypresses will be directed to the combobox.
  1310.  
  1311. Usage:
  1312.  
  1313.   See the included program checkbox.bas for an example of how to use checkboxes.
  1314.  
  1315. __________________________________________________________
  1316.  
  1317. Radiobutton
  1318.  
  1319. Adds a radiobutton control to the window referenced by #handle.  Radiobuttons
  1320. have two states, set and reset.  They are useful for getting input of on/off
  1321. type information.
  1322.  
  1323. The syntax of this command is:
  1324.  
  1325.   radiobutton #handle.ext, "label", [set], [reset], xOrg, yOrg, wide, high
  1326.  
  1327. All radiobuttons on a given window are linked together, so that if you set one
  1328. by clicking on it, all the others will be reset.
  1329.  
  1330. Here is a description of the parameters of the RADIOBUTTON statement:
  1331.  
  1332.     #handle  -  This must be the same as the #handle of the window you are
  1333.         adding the statictext to.  If #handle.ext is used, this
  1334.         allows your program to print commands to the
  1335.         statictext control (otherwise all you'll be able to do is
  1336.         set it and forget it).
  1337.  
  1338.     "label"     - This contains the visible text of the radiobutton
  1339.  
  1340.     [set]       - This is the branch label to goto when the user sets the 
  1341.         radiobutton by clicking on it.
  1342.  
  1343.     [reset]     - This is the branch label to goto when the user resets the
  1344.         radiobutton by clicking on it. (this doesn't actually do 
  1345.         anything because radiobuttons can't be reset by clicking on
  1346.         them).
  1347.  
  1348.     xOrg       - This is the x position of the radiobutton relative to the upper 
  1349.         left corner of the window it belongs to.
  1350.  
  1351.     yOrg        - This is the y position of the radiobutton relative to the upper 
  1352.         left corner of the window it belongs to.
  1353.  
  1354.     wide        - This is the width of the radiobutton control
  1355.  
  1356.     high        - This is the height of the radiobutton control
  1357.  
  1358.  
  1359. Radiobuttons understand these commands:
  1360.  
  1361.     print #handle.ext, "set"
  1362.  
  1363.       This sets the radiobutton.
  1364.  
  1365.  
  1366.     print #handle.ext, "reset"
  1367.  
  1368.       This resets the radiobutton.
  1369.  
  1370.  
  1371.     print #handle.ext, "value?"
  1372.  
  1373.       This returns the status of the radiobutton.  Follow this statement with:
  1374.  
  1375.     input #handle.ext, result$
  1376.  
  1377.       The variable result$ will be either "set" or "reset".
  1378.  
  1379.  
  1380. print #handle.ext, "setfocus"
  1381.  
  1382.     This will cause the radiobutton to receive the input focus.  This means 
  1383.     that any keypresses will be directed to the radiobutton.
  1384.  
  1385. Usage:
  1386.  
  1387.   See the included program radiobtn.bas for an example of how to use radiobuttons.
  1388.  
  1389. __________________________________________________________
  1390.  
  1391. Groupbox
  1392.  
  1393. Like statictext, groupbox lets you place instructions or labels into your windows.
  1394. But groupbox also draws a box that can be used to group related dialog box
  1395. components.
  1396.  
  1397. The syntax of this command is:
  1398.  
  1399.   GROUPBOX #handle, "string", xpos, ypos, wide, high
  1400.  
  1401.   #handle  -  This must be the same as the #handle of the window you are
  1402.         adding the groupbox to.
  1403.  
  1404.   "string"  -  This is the text component of the groupbox.
  1405.  
  1406.   xpos & ypos  -  This is the distance of the groupbox in x and y (in pixels)
  1407.         from the upper-left corner of the screen.
  1408.  
  1409.   wide & high  -  This is the width and height of the groupbox.
  1410.  
  1411.  
  1412. For an example of how groupbox is used, see the included source file dialog3.bas.
  1413.  
  1414. NOTE  -  Groupboxes do not work with windows of type dialog (this is bug in
  1415. Liberty BASIC), but only with windows of type graphics or window.  Instead of
  1416. groupbox, try using statictext to label groups of controls.  Make sure also that
  1417. the controls you wish to contain with the groupbox are listed after the groupbox
  1418. statement.
  1419.  
  1420. ___________________________________________________________
  1421.  
  1422. Statictext
  1423.  
  1424. Statictext lets you place instructions or labels into your windows.  This is
  1425. most often used with a textbox to describe what to type into it.
  1426.  
  1427. The syntax of this command is:
  1428.  
  1429.   STATICTEXT #handle, "string", xpos, ypos, wide, high
  1430.  
  1431.     or
  1432.  
  1433.   STATICTEXT #handle.ext, "string", xpos, ypos, wide, high
  1434.  
  1435.  
  1436.   #handle  -  This must be the same as the #handle of the window you are
  1437.         adding the statictext to.  If #handle.ext is used, this
  1438.         allows your program to print commands to the
  1439.         statictext control (otherwise all you'll be able to do is
  1440.         set it and forget it).
  1441.         
  1442.   "string"  -  This is the text component of the statictext.
  1443.  
  1444.   xpos & ypos  -  This is the distance of the statictext in x and y (in pixels) 
  1445.         from the upper-left corner of the screen.
  1446.  
  1447.   wide & high  -  This is the width and height of the statictext.  You must 
  1448.         specify enough width and height to accomodate the text in 
  1449.         "string".
  1450.  
  1451. Statictext understands only this command:
  1452.  
  1453.     print #handle.ext, "a string"
  1454.  
  1455. This sets the contents (the visible label) of the statictext to be "a string". 
  1456. The handle must be of form #handle.ext so that you can print to the control.
  1457.  
  1458.     'sample program
  1459.  
  1460.     statictext #member, "Name", 10, 10, 40, 18
  1461.     statictext #member, "Address", 10, 40, 70, 18
  1462.     statictext #member, "City", 10, 70, 60, 18
  1463.     statictext #member, "State", 10, 100, 50, 18
  1464.     statictext #member, "Zip", 10, 130, 30, 18
  1465.  
  1466.     textbox #member.name, 90, 10, 180, 25
  1467.     textbox #member.address, 90, 40, 180, 25
  1468.     textbox #member.city, 90, 70, 180, 25
  1469.     textbox #member.state, 90, 100, 30, 25
  1470.     textbox #member.zip, 90, 130, 100, 25
  1471.  
  1472.     button #member, "&OK", [memberOK], UL, 10, 160
  1473.  
  1474.     WindowWidth = 300 : WindowHeight = 230
  1475.     open "Enter Member Info" for dialog as #member
  1476.  
  1477.     input r$
  1478.  
  1479. [memberOK]
  1480.  
  1481.     print #member.name, "!contents?" : input #member.name, name$
  1482.     print #member.address, "!contents?" : input #member.address, address$
  1483.     print #member.city, "!contents?" : input #member.city, city$
  1484.     print #member.state, "!contents?" : input #member.state, state$
  1485.     print #member.zip, "!contents?" : input #member.zip, zip$
  1486.  
  1487. (Listing continues on next page...)
  1488.  
  1489.     cr$ = chr$(13)
  1490.     note$= name$ + cr$ + address$ + cr$ + city$ + cr$ + state$ + cr$ + zip$
  1491.     notice "Member Info" + cr$ + note$
  1492.  
  1493.     close #member
  1494.     end
  1495.  
  1496. ___________________________________________________________
  1497.  
  1498. Trapping the Close event
  1499.  
  1500. It is useful for Liberty BASIC program windows to trap the close event.
  1501. This keeps the windows from closing, and directs program flow to a branch
  1502. label that your program specifies.  At that place in your program you can
  1503. decide to ask for verification that the window should be closed, and/or
  1504. perform some sort of cleanup (closing files, writing ini data, etc.).
  1505.  
  1506. The trapclose command works with all window types.
  1507.  
  1508. Here is the format for trapclose:
  1509.  
  1510.   print #handle, "trapclose branchLabel"
  1511.  
  1512.     This will tell Liberty BASIC to continue execution of the program at
  1513.     branchLabel if the user double clicks on the system menu box
  1514.     or pulls down the system menu and selects close (see buttons1.bas
  1515.     example below).
  1516.  
  1517.  
  1518.   The trapclose code in buttons1.bas looks like this:
  1519.  
  1520.     open "This is a turtle graphics window!" for graphics_nsb as #1
  1521.     print #1, "trapclose [quit]"
  1522.  
  1523. [loop]    ' stop and wait for buttons to be pressed
  1524.     input a$
  1525.     goto [loop]
  1526.  
  1527. Then the code that is executed when the window is closed looks like this:
  1528.  
  1529. [quit]
  1530.     confirm "Do you want to quit Buttons?"; quit$
  1531.     if quit$ = "no" then [loop]
  1532.     close #1
  1533.     end
  1534.  
  1535. Since this only works when the program is halted at an input statement, the
  1536. special variable TrapClose permits detection of the window close when you
  1537. are running a continuous loop that doesn't stop to get user input.  As long as
  1538. TrapClose <> "true", then the window has not been closed.  Once it has been
  1539. determined that TrapClose = "true", then it must be reset to "false" via the
  1540. BASIC LET statement.
  1541.  
  1542. See clock.bas for an example.
  1543.