home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / libbasic / windows.txt < prev    next >
Text File  |  1992-09-16  |  30KB  |  813 lines

  1.  
  2.   WINDOW DEVICE COMMANDS
  3.   ---------------------------------------------------------------------------------------
  4.  
  5.   In Liberty BASIC windows are treated like files, and we can refer
  6.   to anything in this class as a BASIC 'Device'.  To open a window
  7.   we use the OPEN statement, and to close the window we use the
  8.   CLOSE statement.  To control the window we 'print' to it, just as
  9.   we would print to a file.  The commands are sent as strings to the
  10.   device.  As a simple example, here we will open a graphics window,
  11.   center a pen (like a Logo turtle), and draw a simple spiral.  We
  12.   will then pause by opening a simple dialog.  When you confirm the
  13.   exit, we will close the window:
  14.  
  15.     button #graph, Exit, [exit], LR, 5, 5    'window will have a button 
  16.     open "Example" for graphics as #graph    'open graphics window
  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 30                    'draw 30 spiral segments
  21.       print #graph, "go "; index           'go foreward 'index' places
  22.       print #graph, "turn 118"             'turn 118 degrees
  23.     next index                             'loop back 30 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.  
  37.  
  38.   WINDOW TYPES:
  39.   ---------------------------------------------------------------------------------------
  40.  
  41.   Liberty BASIC provides ten different kinds of window types, to which you
  42.   can add as many buttons and pull-down menus as needed.  Here is a list of
  43.   the different kinds:
  44.  
  45.     graphics
  46.         - open a graphic window
  47.     graphics_fs
  48.         - open a graphic window full screen (size of the screen)
  49.     graphics_nsb
  50.         - open a graphic window w/no scroll bars
  51.     graphics_fs_nsb
  52.         - open a graphic window full screen, w/no scroll bars
  53.  
  54.     text
  55.         - open a text window
  56.     text_fs
  57.         - open a text window full screen
  58.     text_nsb
  59.         - open a text window w/no scroll bars
  60.     text_nsb_ins
  61.         - open a text window w/no scroll bars, with inset editor
  62.           so that buttons can be placed around it
  63.     text_fs_nsb
  64.         - open a text window full screen, w/no scroll bars
  65.  
  66.     spreadsheet
  67.         - open a spreadsheet window
  68.  
  69.  
  70.  
  71.   The way that you would specify what kind of window to open would be
  72.   as follows:
  73.  
  74.     open "Window Title" for type   as #handle
  75.  
  76.   where type  would be one of the above ten descriptors
  77.  
  78.  
  79.  
  80.   CONTROLLING SIZE AND PLACEMENT OF WINDOWS
  81.   --------------------------------------------------------------------------------------
  82.  
  83.   The size and placement of any window can be easily determined before
  84.   it is opened in Liberty BASIC (except for any window type with a _fs in its
  85.   descriptor).  If you do choose not to specify the size and placement of
  86.   the windows that your programs open, Liberty BASIC will pick default sizes.
  87.   However, for effect it is often best that you exercise control over this matter.
  88.  
  89.   There are four special variables that you can set to select the size and
  90.   placement of your windows, whether they be text, graphics, or
  91.   spreadsheet:
  92.  
  93.           UpperLeftX, UpperLeftY, WindowWidth, and WindowHeight
  94.  
  95.   Set UpperLeftX and UpperLeftY to the number of pixels from the
  96.   upper-left corner of the screen to position the window.  Often determining
  97.   the distance from the upper-left corner of the screen is not as important
  98.   as determining the size of the window.
  99.  
  100.   Set  WindowWidth and WindowHeight to the number of pixels wide and
  101.   high that you want the window to be when you open it.
  102.  
  103.   Once you have determined the size and placement of your window, then
  104.   open it.  Here is an example:
  105.  
  106.  
  107.   [openStatus]
  108.  
  109.       UpperLeftX = 32
  110.       UpperLeftY = 32
  111.       WindowWidth = 190
  112.       WindowHeight = 160
  113.  
  114.       open "Status Window" for spreadsheet as #stats
  115.  
  116.  
  117.   This will open a window 32 pixels from the corner of the screen, and with
  118.   a width of 190 pixels, and a height of 160 pixels.
  119.  
  120.  
  121.  
  122.   BUTTONS
  123.   ---------------------------------------------------------------------------------------
  124.  
  125.  Buttons are easily added to Liberty BASIC windows.  The format is simple:
  126.  
  127.     button #handle, "Label", [branchLabel], corner, distX, distY
  128.     open "A Window!" for graphics as #handle
  129.  
  130.   By placing at least one button statement before  the open statement, we can
  131.   add button(s) to the window.  Let's examine each part of the button statement:
  132.  
  133.     #handle - This needs to be the same as the handle of the window.
  134.  
  135.     "Label" - This is the text displayed on the button.  If only one word is used,
  136.                           then the quotes are optional.
  137.  
  138.     [branchLabel] - This controls what the button does.  When the user clicks
  139.                                   on the button, then program execution continues at
  140.                                   [branchLabel] as if the program had encountered a
  141.                                   goto [branchLabel] statement.
  142.  
  143.     corner, distX, distY - Corner is used to indicate which corner of the
  144.                                    window to anchor the button to.  DistX and distY
  145.                                    specify how far from that corner in x and y to place
  146.                                    the button.  The following values are permitted for
  147.                                    corner:
  148.  
  149.                       UL - Upper Left Corner
  150.                       UR - Upper Right Corner
  151.                       LL - Lower Left Corner
  152.                       LR - Lower Right Corner
  153.  
  154.   Whenever a running program sits idle at an input statement, it is possible
  155.   for a button-press to effect some action.  If any button is pressed while
  156.   the program is busy doing something else, the button-press will be
  157.   buffered and read later when an input statement is encountered.
  158.  
  159.  
  160.  
  161.   MENUS
  162.   ---------------------------------------------------------------------------------------
  163.  
  164.   Menus are easily added to Liberty BASIC windows.  The format is simple:
  165.  
  166.     menu #handle, "Title", "Line1", [branchLabel1], "Line2", [branchLabel2], ...
  167.     open "A Window!" for graphics as #handle
  168.  
  169.   By placing at least one menu statement before  the open statement, we can
  170.   add menu(s) to the window.  Let's examine each part of the menu statement:
  171.  
  172.     #handle - This needs to be the same as the handle of the window.
  173.  
  174.     "Title" - This is the title displayed on the menu bar.  If only one word is used,
  175.                  then the quotes are optional.  By including an ampersand & in
  176.                  front of the character desired, you can turn that character
  177.                  into a hot-key.  For example, if the title is "&Help", the
  178.                  title will appear as Help.
  179.  
  180.     "Line1" and [branchLabel1] - This is a line item seen when the menu is
  181.              pulled down.  [branchLabel1] is the place where execution continues
  182.              if this menu item is selected.  Like "Title", "Line1"  requires quotes
  183.              only if there is more than one word.  The ampersand & character is
  184.              used to assign a hot-key to the label, as in "Title", above.
  185.  
  186.     "Line2" and [branchLabel2] - This is a second line item and branch
  187.              label for the menu.  You can have as many is needed, going on
  188.              with "Line3 . . . 4 . . .  5", etc.
  189.  
  190.   Adding seperators between menu items to group them is easy.  Simply add a
  191.   bar | character between each group of items.  For example:
  192.  
  193.     . . . "&Red", [colorRed], |, "&Size", [changeSize] . . .
  194.  
  195.     adds a line seperator between the Red and Size menu items like so:
  196.  
  197. {Illustration was here}
  198.  
  199.  
  200.   Whenever a running program sits idle at an input statement, it is possible
  201.   for a menu selection to effect some action.  If any menu selection is made
  202.   while the program is busy doing something else, the selection will be
  203.   buffered and read later when an input statement is encountered.
  204.  
  205.  
  206.  
  207.   GRAPHICS
  208.   ---------------------------------------------------------------------------------------
  209.  
  210.   Because graphics can involve many detailed drawing operations,
  211.   Liberty BASIC does not force you to use just one print # statement
  212.   for each drawing task.  If you want to perform several operations
  213.   you can use a single line for each as such:
  214.  
  215.     print #handle, "cls"
  216.     print #handle, "fill black"
  217.     print #handle, "pen up"
  218.     print #handle, "home"
  219.     print #handle, "pen down"
  220.     print #handle, "north"
  221.     print #handle, "go 50"
  222.  
  223.   Or if you prefer:
  224.  
  225.     print #handle, "cls ; fill black ; pen up ; home ; pen down ; north ; go 50"
  226.  
  227.   will work just as well, and executes slightly faster.
  228.  
  229.  
  230.   print #handle, "\text"
  231.  
  232.     Display text at the current pen position.  Each additional \ in the
  233.     text will cause a carraige return and line feed.  Take for example,
  234.     print #handle, "\text1\text2" will cause text1 to be printed at the
  235.     pen position, and then text2 will be displayed directly under text1.  
  236.  
  237.  
  238.   print #handle, "cls"
  239.  
  240.     Clear the graphics window to white, erasing all drawn elements
  241.  
  242.  
  243.   print #handle, "fill COLOR"
  244.  
  245.     Fill the window with COLOR.  For a list of accepted colors see
  246.     the color command below.
  247.  
  248.  
  249.   print #handle, "up"
  250.  
  251.     Lift the pen up.  All go or goto commands will now only move the
  252.     pen to its new position without drawing.  Any other drawing 
  253.     commands will simply be ignored until the pen is put back down.
  254.  
  255.  
  256.   print #handle, "down"
  257.  
  258.     Just the opposite of up.  This command reactivates the drawing
  259.     process.
  260.  
  261.  
  262.   print #handle, "color COLOR"
  263.  
  264.     Set the pen's color to be COLOR.
  265.  
  266.     Here is a list of valid colors (in alphabetical order):
  267.  
  268.       black, blue, brown, cyan, darkblue, darkcyan, darkgray,
  269.       darkgreen, darkpink, darkred, green, lightgray, palegray,
  270.       pink, red, white, yellow
  271.  
  272.   print #handle, "backcolor COLOR"
  273.  
  274.     This command sets the color used when drawn figures are filled with a
  275.     color.  The same colors are available as with the color command above.
  276.  
  277.   print #handle, "goto X Y"
  278.  
  279.     Move the pen to position X Y.  Draw if the pen is down.
  280.  
  281.  
  282.   print #handle, "place X Y"
  283.  
  284.     Position the pen at X Y.  Do not draw even if the pen is down.
  285.  
  286.  
  287.   print #handle, "go D"
  288.  
  289.     Go foreward D distance from the current position, and going in the
  290.     current direction.
  291.  
  292.  
  293.   print #handle, "north"
  294.  
  295.     Set the current direction to 270 (north).  Zero degrees points to the
  296.     right (east), 90 points down (south), and 180 points left (west).
  297.  
  298.  
  299.   print #handle, "turn A"
  300.  
  301.     Turn from the current direction using angle A and adding it to the
  302.     current direction.  A can be positive or negative.
  303.  
  304.  
  305.   print #handle, "line X1 Y1 X2 Y2"
  306.  
  307.     Draw a line from point X1 Y1 to point X2 Y2.  If the pen is up, then
  308.     no line will be drawn, but the pen will be positioned at X2 Y2.
  309.  
  310.  
  311.   print #handle, "posxy"
  312.  
  313.     Return the position of the pen in x, y.  This command must be followed by:
  314.  
  315.       input #handle, xVar, yVar
  316.  
  317.     which will assign the pen's position to xVar & yVar
  318.  
  319.  
  320.   print #handle, "size S"
  321.  
  322.     Set the size of the pen to S.  The default is 1.  This will affect the
  323.     thickness of lines and figures plotted with most of the commands
  324.     listed in this section.
  325.  
  326.  
  327.   print #handle, "flush"
  328.  
  329.     This ensures that drawn graphics 'stick'.  Make sure to issue this
  330.     command at the end of a drawing sequence to ensure that when the
  331.     window is resized or overlapped and redrawn, its image will be
  332.     retained.  To each group of drawn items that is terminated with flush,
  333.     there is assigned a segment ID number.  See segment below.
  334.  
  335.  
  336.   print #handle, "print"
  337.  
  338.     Send the plotted image to the Windows Print Manager for output.
  339.  
  340.  
  341.   print #handle, "font facename width height"
  342.  
  343.     Set the pen's font to the specified face, width and height.  If an
  344.     exact match cannot be found, then Liberty BASIC will try to find a
  345.     close match, with size being of more prominance than face.
  346.  
  347.  
  348.   print #handle, "circle r"
  349.  
  350.     Draw a circle with radius r at the current pen position.
  351.  
  352.  
  353.   print #handle, "circlefilled r"
  354.  
  355.     Draw a circle with radius r, and filled with the color specified using
  356.     the command backcolor (see above).
  357.  
  358.  
  359.   print #handle, "box x y"
  360.  
  361.     Draw a box using the pen position as one corner, and x, y as the
  362.     other corner.   print #handle, "boxfilled x y"
  363.  
  364.     Draw a box  using the pen position as one corner, and x, y as the other corner.
  365.     Fill the box with the color specified using the command backcolor (see above).
  366.  
  367.  
  368.   print #handle, "ellipse w h"
  369.  
  370.     Draw an ellipse at the pen position of width w and height h.
  371.  
  372.  
  373.   print #handle, "ellipsefilled  w h"
  374.  
  375.     Draw an ellipse at the pen position of width w and height h.  Fill the ellipse
  376.     with the color specified using the command backcolor (see above).
  377.  
  378.  
  379.   print #handle, "pie w h angle1 angle2"
  380.  
  381.     Draw a pie slice inside of an ellipse of width w and height h.  Start the pie
  382.     slice at angle1, and then sweep clockwise angle2 degrees if angle2 is
  383.     positive, or sweep counter-clockwise angle2 degrees if angle2 is negative.
  384.  
  385.  
  386.   print #handle, "piefilled w h angle1 angle2"
  387.  
  388.     Draw a pie slice inside of an ellipse of width w and height h.  Start the slice
  389.     at angle1, and then sweep clockwise angle2 degrees if angle2 is positive,
  390.     or sweep counter-clockwise angle2 degrees if angle2 is negative.  Fill the
  391.     pie slice with the color specified using the command backcolor (see above).
  392.  
  393.  
  394.   print #handle, "segment"
  395.  
  396.     This causes the window to return the segment ID of the most recently
  397.     flushed drawing segment.  This segment ID can then be retrieved
  398.     with an input #handle, varName and varName will contain the segment
  399.     ID number.  Segment ID numbers are useful for manipulating different
  400.     parts of a drawing.  For an example, see delsegment below.
  401.  
  402.  
  403.   print #handle, "delsegment n"
  404.  
  405.     This causes the drawn segment identified as n to be removed from the
  406.     window's list of drawn items.  Then when the window is redrawn the
  407.     deleted segment will not be included in the redraw.
  408.  
  409.  
  410.   print #handle, "redraw"
  411.  
  412.     This will cause the window to redraw all flushed drawn segments.  Any
  413.     deleted segments will not be redrawn (see delsegment above).  Any items
  414.     drawn since the last flush will not be redrawn either, and will be lost.
  415.  
  416.  
  417.   print #handle, "discard"
  418.  
  419.     This causes all drawn items since the last flush to be discarded, but does not
  420.     not force an immediate redraw, so the items that have been discarded will
  421.     still be displayed until a redraw (see above).
  422.  
  423.  
  424. print #handle, "trapclose branchLabel"
  425.  
  426.     This will tell Liberty BASIC to continue execution of the program at 
  427.     branchLabel if the user double clicks on the system menu box
  428.     or pulls down the system menu and selects close (see buttons1.bas
  429.     example below).
  430.  
  431.  
  432. {Illustration was here}
  433.  
  434.  
  435.   The trapclose code in buttons1.bas looks like this:
  436.  
  437.     open "This is a turtle graphics window!" for graphics_nsb as #1
  438.     print #1, "trapclose [quit]"
  439.  
  440. [loop]    ' stop and wait for buttons to be pressed
  441.     input a$
  442.     goto [loop]
  443.  
  444.  
  445.   And then the code that is executed when the window is closed looks like this:
  446.  
  447. [quit]
  448.     confirm "Do you want to quit Buttons?"; quit$
  449.     if quit$ = "no" then [loop]
  450.     close #1
  451.     end
  452.  
  453.  
  454.   Since this only works when the program is halted at an input statement, the
  455.   special variable TrapClose permits detection of the window close when you
  456.   are running a continuous loop that doesn't stop to get user input.  As long as
  457.   TrapClose <> "true", then the window has not been closed.  Once it has been
  458.   determined that TrapClose = "true", then it must be reset to "false" via the
  459.   BASIC LET statement.  See clock.bas for an example. 
  460.  
  461.   print #handle, "when event branchLabel"
  462.  
  463.     This tells the window to process mouse events.  These events occur
  464.     when someone clicks, double-clicks, drags, or just moves the mouse
  465.     inside of the graphics window.  This provides a really simple mechanism
  466.     for controlling flow of a program which uses the graphics window.  For
  467.     an example, see the program draw1.bas.
  468.  
  469.     Sending print #handle, "when leftButtonDown [startDraw]" to any
  470.     graphics window will tell that window to force a goto [startDraw] when
  471.     the mouse points inside of that window and someone press the left mouse
  472.     button down.
  473.  
  474.     Whenever a mouse event does occur, Liberty BASIC places the x and y
  475.     position of the mouse in the variables MouseX, and MouseY.  The
  476.     values will represent the number of pixels in x and y the mouse was from
  477.     the upper left corner of the graphic window display pane.
  478.  
  479.     If the expression print #handle, "when event" is used, then trapping
  480.     for that event is discontinued.  It can however be reinstated at any time.
  481.  
  482.     Events that can be trapped:
  483.  
  484.       leftButtonDown - the left mouse button is now down
  485.       leftButton Up - the left  mouse button has been released
  486.       leftButtonMove - the mouse moved while the left button is down
  487.       leftButtonDouble - the left button has been double-clicked
  488.       rightButtonDown - the right mouse button is now down
  489.       rightButton Up - the right  mouse button has been released
  490.       rightButtonMove - the mouse moved while the right button is down
  491.       rightButtonDouble - the right button has been double-clicked
  492.       mouseMove - the mouse moved when no button was down
  493.  
  494.  
  495.  
  496.   SPREADSHEET  
  497.   ---------------------------------------------------------------------------------------
  498.  
  499.   The spreadsheet used in Liberty BASIC is composed of 35 rows of 26
  500.   columns labeled from A to Z.  The upper-left-most cell is A1 and the
  501.    lower-right-most cell is Z35.  Each cell can contain one of three types
  502.    of data:  string, number, or formula.  To enter one of these three types into
  503.    any cell, simply move the selector over the cell on the spreadsheet
  504.    and begin typing.  When done entering that cell's   contents, press 'Return'.
  505.  
  506.    A string is entered by preceding it with an apostrophe '.  Each cell
  507.    is 11 characters wide so if the string is longer than 11 characters
  508.    it will run into the next cell to its right.
  509.  
  510.    A number is entered by entering its value, either an integer or a
  511.    floating point number.
  512.  
  513.    A formula is a simple arithmatic expression, using numbers (see above) or
  514.    cell references.  The result of the formula is displayed  in the cell's position.
  515.    Any arithmatic precedence is ignored, so any formula is always evaluated
  516.    from left to right and parenthesis are not permitted (They aren't needed).
  517.  
  518.      A formula to compute the average of 3 cells might be:     a1 + a2 + a3 / 3       
  519.  
  520.   The spreadsheet is a very special widget.  Alone it is a very simple
  521.   but complete spreadsheet.  But being able to send it commands and data
  522.   and to be able to read back data from it via Liberty BASIC makes it
  523.   a very powerful tool.  For examples, see grapher.bas and customer.bas.
  524.  
  525.   Modes:
  526.   The spreadsheet has two modes, manual and indirect.  Manual mode means that
  527.   that the operator can freely move about from cell to cell with the arrow keys.
  528.   He/she can also insert formulas in manual mode.  Using  indirect mode, the user
  529.   can only move to cells predefined by the controlling application, which also
  530.   decides what type of data is contained by each cell, either string or number.
  531.  
  532.  
  533.   Here are the commands:
  534.  
  535.  
  536.   print #handle, "manual"
  537.  
  538.     The manual mode is the default setting.  This mode permits the
  539.     user to move the cell selector wherever he/she wants and to
  540.     enter any of three data types into any cell: number, string, formula
  541.  
  542.  
  543.   print #handle, "format COLUMN right|fixed|none"
  544.  
  545.     This command lets the application control formatting for an individual
  546.     column (COLUMN can be any letter A .. Z).  
  547.  
  548.     right - right justify column
  549.     fixed - assume 2 decimal places for numbers, and right justify also
  550.     none - left justify, default
  551.  
  552.  
  553.  
  554.   print #handle, "indirect"
  555.  
  556.     The indirect mode is the most useful when using a spreadsheet for
  557.     data entry.  It enables the application to control which cells the
  558.     user has access to, and what kind of information they can contain.
  559.  
  560.  
  561.   print #handle, "cell ADDRESS CONTENTS"
  562.  
  563.     Place CONTENTS into the cell at ADDRESS.  ADDRESS can be any cell
  564.     address from A1 to Z35.  The letter A to Z must be in uppercase.
  565.     CONTENTS can be any valid string, number or formula (see above).
  566.  
  567.  
  568.   print #handle, "user ADDRESS string|number"
  569.   
  570.     Set aside the cell at ADDRESS (same rules apply as for ADDRESS in
  571.     command cell, above) as a user cell and specify the data it
  572.     contains to be either a string or a number (data entered will be
  573.     automatically converted to correct type).  This command is only
  574.     effective when indirect mode is in effect (see above).
  575.  
  576.  
  577.   print #handle, "select ADDRESS"
  578.  
  579.     Place the selector over the cell at ADDRESS (again, same rules).
  580.     It is important to place the selector over the first cell that
  581.     the user will edit.
  582.  
  583.  
  584.   print #handle, "result? ADDRESS"
  585.  
  586.     Answer the result or value of the cell at ADDRESS (again, same
  587.     rules).  If ADDRESS is not a valid cell address, then an empty
  588.     string will be returned.  This command must be followed by:
  589.  
  590.     input #handle, var$  (or  input #handle, var  if number expected)
  591.  
  592.     which will leave the desired cell's contents in var$  (or var)
  593.  
  594.  
  595.   print #handle, "formula? ADDRESS"
  596.  
  597.     Answer the formula of the cell at ADDRESS (again, same rules).
  598.     This command must also be followed with:
  599.  
  600.     input #handle, var$  (should always be a string returned)
  601.  
  602.     which will leave the desired cell's formula in var$
  603.  
  604.  
  605.   print #handle, "flush"
  606.  
  607.     This commands forces the spreadsheet to display its most up to
  608.     date results.
  609.  
  610.  
  611.   print #handle, "load pathFileName"
  612.  
  613.     This causes a Liberty BASIC spreadsheet file (which always have
  614.     an .abc extension) named pathFileName to be loaded, replacing
  615.     the current data set.
  616.  
  617.  
  618.   print #handle, "save pathFileName"
  619.  
  620.     This causes spreadsheet data set (which will always have
  621.     an .abc extension) to be saved to disk at pathFileName.
  622.  
  623.  
  624.   print #handle, "modified?"
  625.  
  626.     This returns a string (either "true" or "false") that indicates whether any
  627.     data in the spreadsheet has been modified.  This is useful for checking
  628.     to see whether to save the contents of the window before closing it.
  629.  
  630.     To read the result, an input #handle, varName$, must be performed
  631.     after.
  632.  
  633.  
  634.   print #handle, "nolabels"
  635.  
  636.     This turns off the row and column labels.
  637.  
  638.  
  639.   print #handle, "labels"
  640.  
  641.     This turns on the row and column labels.
  642.  
  643.  
  644.   print #handle, "trapclose branchLabel"
  645.  
  646.     This will tell Liberty BASIC to continue execution of the program at
  647.     branchLabel if the user double clicks on the system menu box
  648.     or pulls down the system menu and selects close (see rolodex1.bas).
  649.  
  650.     See the text for trapclose in the above graphic window section for a
  651.     more complete explanation.
  652.  
  653.  
  654.   TEXT WINDOW
  655.   ---------------------------------------------------------------------------------------
  656.  
  657.   The text window works a little differently.  Whatever you print to a
  658.   text window is displayed exactly as sent.  The way to send commands to
  659.   a text window is to make the ! character the first character in the string.
  660.   It is also important to add a semicolon to the end of command line (a
  661.   print #handle line with text window commands) as in the example below.
  662.   If you don't, the print statement will force a carraige return into the text
  663.   window each time you print a command to the window if you don't.
  664.  
  665.   For example:
  666.  
  667.   open "Example" for text as #1        'open a text window
  668.     print #1, "Hello World"            'print Hello World in the window
  669.     print #1, "!font helv 16 37" ;       'change the text window's font 
  670.     print #1, "!line 1" ;               'read line 1
  671.     input #1, string$
  672.     print "The first line of our text window is:"
  673.     print string$
  674.     input "Press 'Return'"; r$
  675.   close #1                             'close the window
  676.  
  677.  
  678.   Here are the text window commands:
  679.  
  680.  
  681.   print #handle, "!cls" ;
  682.  
  683.     Clears the text window of all text.
  684.  
  685.  
  686.   print #handle, "!font faceName width height" ;
  687.  
  688.     Sets the font of the text window to the specified face of width and
  689.     height.  If an exact match cannot be found, then Liberty BASIC will
  690.     try to match as closely as possible, with size figuring more
  691.     prominently than face in the match.
  692.  
  693.  
  694.   print #handle, "!line #" ;
  695.  
  696.     Returns the text at line #.  If # is less than 1 or greater than the
  697.     number of lines the text window contains, then "" (an empty string)
  698.     is returned.  After this command is issued, it must be followed by:
  699.  
  700.     input #handle, string$
  701.  
  702.     which will assign the line's text to string$
  703.  
  704.  
  705.   print #handle, "!lines" ;
  706.  
  707.     Returns the number of lines in the text window.  After this command
  708.     is issued, it must be followed by:
  709.  
  710.     input #handle, countVar
  711.  
  712.     which will assign the line count to countVar
  713.  
  714.  
  715.  
  716.   print #handle, "!modified?" ;
  717.  
  718.     This returns a string (either "true" or "false") that indicates whether any
  719.     data in the text window has been modified.  This is useful for checking
  720.     to see whether to save the contents of the window before closing it.
  721.  
  722.     To read the result, an input #handle, varName$, must be performed
  723.     after.
  724.  
  725.  
  726.   print #handle, "!selection?" ;
  727.  
  728.     This returns the highlighted text from the window.  To read the result
  729.     an input #handle, varName$ must be performed after.
  730.  
  731.  
  732.   print #handle, "!selectall" ;
  733.  
  734.     This causes everything in the text window to be selected.
  735.  
  736.  
  737.   print #handle, "!copy" ;
  738.  
  739.     This causes the currently selected text to be copied to the
  740.     WINDOWS clipboard.
  741.  
  742.  
  743.   print #handle, "!cut" ;
  744.  
  745.     This causes the currently selected text to be cut out of the
  746.     text window and copied to the WINDOWS clipboard.
  747.  
  748.  
  749.   print #handle, "!paste" ;
  750.  
  751.     This causes the text in the WINDOWS clipboard (if there is any) to be
  752.     pasted into the text window at the current cursor position.
  753.  
  754.  
  755.   print #handle, "!origin?" ;
  756.  
  757.     This causes the current text window origin to be returned.  When a text
  758.     window is first opened, the result would be row 1, column 1.  To read the
  759.     result an input #handle, rowVar, columnVar must be performed after.
  760.  
  761.  
  762.   print #handle, "!origin row column" ;
  763.  
  764.     This forces the origin of the window to be row and column. 
  765.  
  766.  
  767.   print #handle, "!trapclose branchLabel" ;
  768.  
  769.     This will tell Liberty BASIC to continue execution of the program at
  770.     branchLabel if the user double clicks on the system menu box
  771.     or pulls down the system menu and selects close (see rolodex1.bas).
  772.  
  773.     See the text for trapclose in the above graphic window section for a
  774.     more complete explanation.
  775.  
  776.  
  777.  
  778.   TIPS
  779.   ------------------------------------------------------------------------
  780.   
  781.   - Once its techniques are mastered, the spreadsheet becomes a much better
  782.   mechanism for data entry than do plain INPUT statements in a BASIC
  783.   program's main window.  This is especially true when many items need to
  784.   be entered.  In this case, making the spreadsheet the control center
  785.   for your application might be a good idea.  Just add buttons to the
  786.   spreadsheet to perform needed functions after data is entered.
  787.  
  788.   - Remember, any window can have buttons (except for the main window,
  789.   which is for some applications best kept minimized).  Take advantage of this.
  790.  
  791.   - Many applications do not need the main window at all, and in these cases,
  792.   you can simply include the NOMAINWIN command in your programs, which
  793.   causes the main window to be omitted from your running program.
  794.  
  795.   - Don't forget to take advantage of the PROMPT, CONFIRM, and NOTICE
  796.   statements, which borrow the syntax from the INPUT statement, but do their
  797.   thing in Windows dialogs.  These simple statements can help make your programs
  798.   more Windows-like.
  799.  
  800.   - When running grapher.bas, try pulling down the command menu and
  801.   selecting Open.  Two *.abc files will be offered.  Load one of these
  802.   and click on the Graph button.
  803.  
  804.   - If you want to edit more than one *.bas file at once, after you select a file
  805.   to edit, pull down the Files menu and select BASIC Editor.  A seperate
  806.   editor window will open containing the file you select.  NOTE:  The file that
  807.   is displayed will be the last saved  version, so if you have made changes and
  808.   have not saved them, they will not appear in the newly opened window.
  809.  
  810.   - When drawing graphic figures, you can create a three dimensional effect
  811.   by first drawing each figure in gray or black, and with a slight offset, and then
  812.   drawing the figures on top in some other color.  This creates a shadow effect.
  813.