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

  1. Overview of the Liberty BASIC Environment:
  2.  
  3. This chapter will introduce you to:
  4.  
  5.   The Liberty BASIC browser ;
  6.   The Liberty BASIC Trace Window
  7.   BASIC editors
  8.  
  9.  
  10. The Liberty BASIC browser
  11.  
  12. When you start Liberty BASIC, you get a window that looks like this:
  13.  
  14.  
  15. {Illustration was here}
  16.  
  17.  
  18.  
  19. The window has four panes.  Starting in the upper-left-hand corner, the first
  20. pane is where you select the disk drive on which your work is or will be
  21. stored.  To its right is a pane where you select the directory where your
  22. work is.  The next pane contains a list of *.bas files.  The big pane comprising
  23. the lower half of the window is a source editor, which displays file details (see
  24. illustration above) until you select a file to edit.
  25.  
  26. Each of the panes in the browser has a pull-down menu.  Each pull-down menu
  27. can also be popped-up.  To pop up a menu, point into that pane with the mouse
  28. and press the right-hand mouse button once.  We will use the pull-down menus
  29. for our examples here.
  30.  
  31.  
  32. Let's begin by creating a BASIC program file.  Pull down the Files menu and
  33. select Create.  
  34.  
  35.  
  36.  
  37.  
  38. {Illustration was here}
  39.  
  40.  
  41.  
  42.  
  43. You will be asked to type the name of your new BASIC program.  Type
  44. ellipses, then strike return or click on OK.
  45.  
  46.  
  47.  
  48.  
  49. {Illustration was here}
  50.  
  51.  
  52.  
  53.  
  54. Then click on Yes or press Enter.
  55.  
  56.  
  57.  
  58.  
  59. {Illustration was here}
  60.  
  61.  
  62.  
  63.  
  64. The file will be created, and you will be given an empty source
  65. editor pane.
  66.  
  67.  
  68.  
  69. Now type in the source code below, so that your window
  70. looks like the illustration.
  71.  
  72.  
  73.     ' draw some ellipses
  74.  
  75.     nomainwin
  76.  
  77.     open "Ellipses" for graphics as #1
  78.     print #1, "down"
  79.     print #1, "place 130 130"
  80.     for x = 30 to 230 step 10
  81.         print #1, "ellipse "; x ; " "; 260 - x
  82.     next x
  83.     print #1, "flush"
  84.     input r$
  85.     close #1
  86.  
  87.  
  88.  
  89.  
  90. {Illustration was here}
  91.  
  92.  
  93.  
  94. Now pull down the File menu and select Save and your program will be
  95. saved to disk.
  96.  
  97.  
  98.  
  99.  
  100. {Illustration was here}
  101.  
  102.  
  103.  
  104.  
  105. Now let's run the program.
  106.  
  107.  
  108.  
  109.  
  110. {Illustration was here}
  111.  
  112.  
  113.  
  114. and we get:
  115.  
  116.  
  117.  
  118. {Illustration was here}
  119.  
  120.  
  121.  
  122.  
  123. Now close the window.
  124.  
  125.  
  126. Using the Debugger:
  127.  
  128. Let's take a closer look at how our ellipses program works using the debugger.
  129. Pull down the Source menu and select Debug.
  130.  
  131.  
  132.  
  133.  
  134. {Illustration was here}
  135.  
  136.  
  137.  
  138.  
  139. A dialog will appear asking if you want to watch variables.  Respond by clicking
  140. on Yes or by pressing Enter.
  141.  
  142.  
  143.  
  144. {Illustration was here}
  145.  
  146.  
  147.  
  148.  
  149. A Trace Window will appear, and also another window labeled
  150. Program named - 'ellipses.bas'
  151.  
  152.  
  153.  
  154. {Illustration was here}
  155.  
  156.  
  157. Select the Trace Window to bring it to the foreground and to make it the active
  158. window.  Notice that it has two panes.  The pane on the top shows variables as
  159. they change value.  The pane on the bottom shows each line of code as it
  160. executes.
  161.  
  162.  
  163.  
  164.  
  165. {Illustration was here}
  166.  
  167.  
  168.  
  169. The three buttons on the bottom of the window let you pick three different
  170. modes of execution:
  171.  
  172.     Step  -  Step one line at a time through program execution
  173.     Walk  -  Run the program non stop highlighting each line as it executes
  174.     Run  -  Run full speed.  Do not highlight each line
  175.  
  176. Program always begins in Step mode when the Debug option is used.
  177.  
  178.  
  179. Now let's click on the Step button once.  Your Trace Window should look
  180. like:
  181.  
  182.  
  183.  
  184. {Illustration was here}
  185.  
  186.  
  187.  
  188.  
  189. Now we see that the nomainwin statement has been executed, the results of
  190. which are not visible.  When we click on Step again, the open statement will
  191. open a graphics window for us labeled Ellipses.  Try it.
  192.  
  193.  
  194.  
  195. {Illustration was here}
  196.  
  197.  
  198.  
  199.  
  200. Now notice that the Trace Window now highlights the next line, and that
  201. a graphics window appears labeled Ellipses.
  202.  
  203.  
  204.  
  205. {Illustration was here}
  206.  
  207.  
  208.  
  209.  
  210. Now click on Step twice more.  The two statements:
  211.  
  212.     print #1, "down"
  213.     print #1, "place 130 130"
  214.  
  215. will be executed.  You won't be able to immediately see the effect of these
  216. two statements.  The first one tells the window's graphic pen to be 'lowered'
  217. to the surface of its 'paper'.  The second statement places the pen at 130
  218. in x and y.
  219.  
  220.  
  221.  
  222. Now click on Step again.  Now look at the variables pane in the Trace Window.
  223.  
  224.  
  225.  
  226. {Illustration was here}
  227.  
  228.  
  229.  
  230.  
  231. This shows that the variable x has been assigned the value 30.  Each and every
  232. time that x (or any other variable), changes, we will be informed as to just what
  233. that change is.
  234.  
  235. Now click on Step again.  The line:
  236.  
  237.     print #1, "ellipse "; x ; " "; 260 - x
  238.  
  239. will be executed, and you will see this:
  240.  
  241.  
  242.  
  243.  
  244. {Illustration was here}
  245.  
  246.  
  247.  
  248.  
  249. Now click on Step a dozen or so times, watching the value of x change and 
  250. seeing several new ellipses drawn.  Finally, click on Walk and the program
  251. will run non-stop, highlighting each line as it goes, and displaying each new
  252. value of x.  When this is done, you may close the graphics window, the
  253. Trace Window, and the window labeled:  Program named: 'ellipses.bas'.
  254. When you close this third window, Liberty BASIC will ask if you want to
  255. terminate ellipses.bas.  Respond by pressing Enter or clicking on Yes. Editing several BASIC files:
  256.  
  257. Only one Liberty BASIC browser can be open at a time.  If you want to edit
  258. more than one *.bas file at a time, you can open seperate BASIC editors on
  259. each one.  A BASIC editor is a window with a single pane for editing, and it
  260. also let's you run and debug.  Let's say you want to edit both hello.bas and
  261. ellipses.bas at the same time.  Starting with the browser window, select
  262. hello.bas so that its source code is visible in the editor pane as shown:
  263.  
  264.  
  265.  
  266.  
  267. {Illustration was here}
  268.  
  269.  
  270.  
  271. Now pull down the Files menu, and select BASIC Editor.
  272.  
  273.  
  274.  
  275. {Illustration was here}
  276.  
  277.  
  278.  
  279.  
  280. Now a BASIC editor window will appear with the contents of hello.bas ready
  281. to edit or run.  The BASIC editor does not have a pull-down menu for running
  282. or debugging.  Instead, it has a pop-up menu for accomplishing the same thing.
  283. To pop up the menu, simply point inside of the pane with the mouse, and push
  284. the right-hand mouse button once.  The menu will appear and you can then
  285. choose what operation you want to perform.
  286.  
  287.  
  288.  
  289. {Illustration was here}
  290.  
  291.  
  292.  
  293.  
  294. Now we can simply go back to the browser and select the other file(s)
  295. that we want to edit or run, only ellipses.bas in this example.
  296.  
  297.  
  298.  
  299. Shortcuts:
  300.  
  301. Here is a list of key combinations that activate useful features in Liberty BASIC:
  302.  
  303.     Shift + Del             Cut
  304.     Ctrl + Ins              Copy
  305.     Shift + Ins             Paste
  306.     Clear                   Del
  307.     Select All              Ctrl + A
  308.     Print Selection         Ctrl + P
  309.     Find/Replace            Ctrl + F
  310.     Find Again              Ctrl + G
  311.     Open Scratchpad Alt + N
  312.     Open a File Editor      Alt + O
  313.     Save                    Alt + S
  314.     Save As                 Alt + A
  315.     Print                   Alt + P
  316.  
  317. These features are also available in the File and Edit pull-down menus.
  318.