home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Samples / BOZOL2 / BOZOL2.ZIP / BOZOL.DOC < prev    next >
Encoding:
Text File  |  1994-02-09  |  27.7 KB  |  619 lines

  1.  
  2.  
  3.         1. WHAT IS BOZOL?
  4.         2. BOZOL COMMANDS AND FUNCTIONS - STARTER SET
  5.         3. BOZOL PROGRAMMING RULES
  6.         4. HOW TO ADD COMMANDS AND FUNCTIONS
  7.         5. CALLING BOZOL FROM YOUR OWN PROGRAMS
  8.  
  9.         1. WHAT IS BOZOL?
  10.  
  11.         BozoL (The Bozo Language) is an extremely simple interpretive
  12.         language written in PowerBASIC.  It is designed to be easy to
  13.         use, easy to modify, and to run as fast as possible.
  14.  
  15.         Some of the rules in BozoL may seem a bit wierd, but there is a
  16.         reason for this.  After writing a BASIC interpreter (EBASIC.ZIP)
  17.         I discovered that the fundamental design of BASIC makes it
  18.         extremely difficult to parse and interpret with any sort of
  19.         reasonable speed.  BozoL is purposely designed to run as fast
  20.         as possible as an interpreted language.
  21.  
  22.         Why BozoL?
  23.  
  24.         Every now and then a situation may arise where you will want to
  25.         incorporate a command language into your programs.  BozoL can be
  26.         easily modified to do things relevant to your program's needs.
  27.         Suppose you have a database program and you want to allow your
  28.         users to program their own custom procedures without having to
  29.         go back to the original source code and add them in.
  30.  
  31.         BozoL is a language skeleton.  All of the dirty work has been
  32.         done already.  BozoL already contains expression parsing, program
  33.         flow control, basic logic, and other fundamental building blocks
  34.         of a programming language (print, input, variables, etc).
  35.  
  36.         BozoL is simple.  There are not a lot of rules, punctuation, or
  37.         wierd symbols in the language.  It is a real beginner's language.
  38.  
  39.         All you need to do now is add your own custom commands and key-
  40.         words to the language.  See section 4, "How to add commands and
  41.         functions" for the exact details on how to do this.
  42.  
  43.         Prototypes and Applications
  44.  
  45.         Suppose you have a library of routines that pop up boxes, print
  46.         menus, display pictures, etc.  You can take these routines and
  47.         make BozoL commands out of them.  For instance, if you have a
  48.         PowerBASIC subroutine that displays a message inside a red box
  49.         on the center of the screen, you can make a BozoL command which
  50.         calls this subroutine.  So now in BozoL you can say
  51.  
  52.                 REDBOX "press any key to continue!"
  53.  
  54.         and BozoL will call your subroutine.  Using this technique, you
  55.         can take an entire library, or many libraries, and make BozoL
  56.         commands out of all of those subroutines.
  57.  
  58.         I'll give you a more advanced example.  Suppose you have a Power-
  59.         BASIC library that features pull-down menus, dialog boxes, list
  60.         boxes, a text editor, and data entry screens.  If you took every
  61.         callable SUB and FUNCTION in this library and made BozoL commands
  62.         out of them, then you could use the BozoL language to write
  63.         really neat user-interface programs, prototypes, or even finished
  64.         products.  Instead of shipping an EXE, you can ship the BozoL
  65.         interpreter along with an interpreted BozoL program that can
  66.         be easily modified by your customers without ever having to
  67.         give them the source code or customizing the program yourself.
  68.  
  69.         Software upgrades could be faxed to your customers or even
  70.         dictated over the phone.
  71.  
  72.         Process Control
  73.  
  74.         You could use BozoL to control machinery.  You could add commands
  75.         like TURN EVERYTHING OFF or DISPLAY STATUS OF MIXER 1.  By inventing
  76.         commands and adding them to the language you could turn BozoL into
  77.         a high level language that does almost anything, for any purpose.
  78.         Users could enter direct statements or run programs that display
  79.         menus and perform certain tasks, and easily add to or modify the
  80.         system without a lot of complicated programming.  Consider these
  81.         possible additions to the language:
  82.  
  83.                 DISPLAY SCHEMATIC
  84.                 BLOCK PHONES
  85.                 ELECTRIC FENCES OFF
  86.                 DISENGAGE SECURITY IN DINOSAUR EMBRYO LAB
  87.  
  88.         With the fundamental building blocks of the language already in
  89.         place (like GOTO, GOSUB, IF, LOAD, RUN, SAVE, PRINT, INPUT, LOCATE,
  90.         COLOR, LET, etc) you can easily build a custom language that works
  91.         well, runs fast, can handle almost any programming task, and can
  92.         call subroutines written in BASIC, C, Assembler, or BozoL.  Since
  93.         most of the nitty gritty is compiled in (like what do do when the
  94.         command BLOCK PHONES is issued) it will almost always seem to
  95.         run just as fast as a compiled program.
  96.  
  97.         2. BOZOL COMMANDS AND FUNCTIONS - STARTER SET
  98.  
  99.         As I mentioned in part 1, all of the fundamental building blocks
  100.         of the language, its structure, variable handling and flow control
  101.         have already been built in.  All you need to do is add new key
  102.         words and the code that is executed when BozoL sees the key word.
  103.  
  104.         These are the key words that are built in to BozoL already:
  105.  
  106.  
  107.          ASC       ASCII     BE        CALC      CASE      CHR       CLS
  108.          COLOR     CR        EQUAL     EQUALS    EVAL      FALSE     GOSUB
  109.          GOTO      IF        IN        INKEY     INPUT     IS        LCASE
  110.          LEFT      LEN       LET       LIST      LOAD      LOCATE    LOWER
  111.          LTRIM     MID       NOT       PRINT     PROMPT    QUIT      RETURN
  112.          RIGHT     RTRIM     RUN       SAME      SAVE      SET       SUBSTR
  113.          TAB       TO        TRUE      UCASE     UNTIL     UPPER     WHAT
  114.          WHILE     WITH
  115.  
  116.         (... and added since this writing...)
  117.  
  118.         END
  119.  
  120.         See the file BOZOL.REF for a complete description of each command
  121.         and examples of how to use them in your programs.
  122.  
  123.         3. BOZOL PROGRAMMING RULES
  124.  
  125.         BozoL is funny for a couple of reasons.  First, the syntax is
  126.         probably unlike any language you have ever seen.  As I mentioned
  127.         earlier, this is to make it easier for the interpreter to
  128.         parse and execute its statements.  Easier means faster.
  129.  
  130.         BozoL also has keywords which don't do anything.  The reason for
  131.         these keywords is to make the awkward syntax a bit easier to
  132.         stomach.  Remember these keywords when adding your own commands
  133.         to BozoL.  They can come in handy.
  134.  
  135.         Keywords that don't do anything:
  136.  
  137.                 "TO", "IN", "WITH", "IS", "BE", "EQUAL", "OF", "THE"
  138.  
  139.         You will see me using these in program examples every once in a while.
  140.         For instance, to assign a value to a variable you could say
  141.  
  142.                 SET A TO 1
  143.  
  144.         Although the word "TO" is not really necessary.  You could also
  145.         say
  146.  
  147.                 SET A 1
  148.  
  149.         but that looks silly and its meaning would not be clear to someone
  150.         who does not know all about BozoL (like anyone does but me!).
  151.  
  152.         Which brings up another rule:  BozoL statements are parsed with
  153.         spaces, commas, or semicolons.  It does not matter which you use
  154.         and it does not matter how you mix them.  For instance, these
  155.         expressions are all the same:
  156.  
  157.                 SET A TO 1
  158.                 SET A,1
  159.                 SET;A;1
  160.                 SET   A   TO   1
  161.  
  162.         Also, multiple statements can be on the same line.  In fact, it
  163.         is necessary to put multiple statements on the same line in some
  164.         cases.  Multiple statements are separated by colons, just like
  165.         BASIC.
  166.  
  167.                 SET A TO 1: PRINT A: PRINT "GoodBye!":END
  168.  
  169.         Now here's another bit of silliness:  BozoL will also allow
  170.         you to place multiple statements on a line without using colons
  171.         to separate them, BUT if you do not use colons the statements will
  172.         be executed in REVERSE ORDER.
  173.  
  174.         For example, if you said
  175.  
  176.                 PRINT 1: PRINT 2: PRINT 3
  177.  
  178.         BozoL would display this on the screen:
  179.  
  180.                 1
  181.                 2
  182.                 3
  183.  
  184.         But if you said
  185.  
  186.                 PRINT 1 PRINT 2 PRINT 3
  187.  
  188.         then BozoL would print this:
  189.  
  190.                 3
  191.                 2
  192.                 1
  193.  
  194.         This is the magic of "stack parsing", which is how BozoL processes
  195.         statements and functions.  For more info on stack parsing, read
  196.         the comments in the source code.
  197.  
  198.         This is not mean't to be funny or wierd.  It is very useful.  For
  199.         example, you could say
  200.  
  201.         WHILE NOT LEN INKEY: NEXT RECORD: PRINT NAME,ADDRESS,PHONE
  202.  
  203.         or you could also say it like this:
  204.  
  205.         PRINT NAME,ADDRESS,PHONE OF THE NEXT RECORD WHILE NOT LEN INKEY
  206.  
  207.         Do you see the difference between the two lines?  There is none.
  208.         In the first line we broke up the sentence with colons to indicate
  209.         a specific order of the actions.  In the second line we said
  210.         everything we wanted to do and with the help of a couple of
  211.         placeholder keywords (OF and THE) which do nothing, and without
  212.         the colons it almost seems like english!
  213.  
  214.         So to review, we have "placeholder" commands which do nothing but
  215.         make the syntax more readable, and we have a language syntax which
  216.         goes forwards or backwards depending on whether or not you use
  217.         colons to separate multiple statements.  If you follow me this
  218.         far then we'll go on.  If not, go back a few pages.
  219.  
  220.         Bozol, as it is right now, leaves out some basic language functions
  221.         which may be considered important.  Particularly file I/O.  There
  222.         are no facilities to open, read, write, or append any sort of
  223.         file except for LOAD and SAVE.  Most of the major string handling
  224.         and arithmetic is included, as well as basic user interface
  225.         primatives: INPUT, PRINT, PROMPT, and INKEY.
  226.  
  227.         BozoL variable names can be any letter or word which does not
  228.         have a numeric value and is not already defined as a keyword.
  229.         A BozoL variable can be of any data type.  BozoL does not
  230.         distinguish between strings and numeric data.  If a BozoL variable
  231.         contains alphabetic characters it is treated as 0 in arithmetic
  232.         functions or functions which require a numeric parameter.
  233.         Variables which contain numeric data (like the number 100) can
  234.         be treated as strings in string functions like LEFT, RIGHT and
  235.         MID, etc.
  236.  
  237.         BozoL programs are limited to 256 defined variables and all
  238.         variables are retained when a new program is RUN.  A BozoL
  239.         program can be no more than 1000 lines in length.  There is
  240.         no effective limit to how many statements can occur on a single
  241.         line.
  242.  
  243.         A line of code in BozoL can contain multiple statements which
  244.         are separated by colons, but it may also contain statements
  245.         separated by carriage return-line feed pairs.  Each line in
  246.         the program can contain up to 32K of statements.  The entire
  247.         BozoL program cannot exceed 64K in size, unless, of course,
  248.         you modify the source code and DIM HUGE the array which contains
  249.         the program.
  250.  
  251.         Error checking is done by the PowerBASIC compiler except where
  252.         necessary.  If an error occurs, BozoL will display an error
  253.         message and ask if you wish to continue the program or exit to
  254.         DOS.  In the BozoL program, only the subroutine PROGRUN terminates.
  255.         If you called PROGRUN from another program your program will
  256.         simply resume.
  257.  
  258.         Entering Statements
  259.  
  260.         By default, BozoL begins in command line mode, like GWBASIC.  You
  261.         can enter direct statements, LOAD, or RUN a program.  When the
  262.         program ends BozoL will return you to the command line unless the
  263.         program is terminated with END or QUIT.
  264.  
  265.         If you preceed a direct statement with a line number from 1 to
  266.         1000, the statement will not be executed.  Instead it will be
  267.         entered into memory.  You can then type LIST to see all of the
  268.         lines currently in memory.  Any blank lines will not be displayed.
  269.  
  270.         To try it out, run BozoL and type these three lines:
  271.  
  272.                 1 PRINT "This is the beginning!"
  273.                 2 BE UNTIL LEN INKEY
  274.                 3 PRINT "This is the end!"
  275.  
  276.         Then type LIST.  BozoL will re-display the lines that you entered.
  277.         Then type the command RUN.  BozoL will print "This is the beginning!"
  278.         and will wait for you to press any key.  After you press any key
  279.         BozoL will print "This is the end!" and the program will terminate,
  280.         leaving you at the BozoL command prompt.
  281.  
  282.         Notice line 2, where we could have just said UNTIL LEN INKEY we
  283.         added the dummy word BE in front of it just because it makes the
  284.         purpose of the line a little more descriptive.
  285.  
  286.         Now if you typed SAVE "PROG1", BozoL would write these three
  287.         lines to a file called "PROG1" in the current directory.  At any
  288.         time in the future you can type LOAD "PROG1" to reload the
  289.         program into memory, and then LIST or RUN, or you can just type
  290.         RUN "PROG1" to load and run the program.  You may have already
  291.         decided that it will be much less of a chore to write your
  292.         programs in an external text editor.  I thought about adding a
  293.         fullscreen editor to BozoL, but the best editor I have (PBWRITE)
  294.         is almost four times larger than all of BozoL by itself.  If
  295.         you want to add a text editor, do it yourself.
  296.  
  297.         You must remember that when you create a program using an editor
  298.         you may not use line numbers.  Line numbers can only be used to
  299.         enter a program at the BozoL command line.  Line numbers are
  300.         not retained by BozoL when a program is saved to disk.
  301.  
  302.         Assigning variables
  303.  
  304.         To assign a value to a variable you can use the SET or LET
  305.         statements.  They both work the same way.  You can use either
  306.         depending on your favorite syntax.
  307.  
  308.                 LET A BE EQUAL TO 1
  309.                 SET NAME TO "ERIK"
  310.  
  311.         Notice the use of the "dummy" keywords BE EQUAL TO and TO in these
  312.         statements.  They are not necessary but can be used to provide
  313.         additional readablility in your source code.
  314.  
  315.         Using functions
  316.  
  317.         Functions (like CHR, LEN, or UCASE) may require variables as
  318.         arguments. Since BozoL does not distinguish between numeric and
  319.         character data types you can use any kind of variable as an
  320.         argument to a function.  Unlike BASIC or any other language,
  321.         arguments to a function are not included in parenthesis.
  322.  
  323.         For example, to print ASCII code 1 in BASIC you would say
  324.  
  325.                 PRINT CHR$(1)
  326.  
  327.         However in BozoL you would say
  328.  
  329.                 PRINT CHR 1
  330.  
  331.         A statement like this in BASIC:
  332.  
  333.                 PRINT LTRIM$(RTRIM$(UCASE$(A$)))
  334.  
  335.         Would look like this in BozoL:
  336.  
  337.                 PRINT LTRIM RTRIM UCASE A
  338.  
  339.         Evaluating expressions
  340.  
  341.         Unlike languages which employ recursive descent parsing, BozoL
  342.         does not naturally incorporate arithmetic into its syntax.  To
  343.         trigger an arithmetic evaluation you must use the CALC keyword.
  344.         CALC has some synonyms which do the exact same thing but may
  345.         be preferred for better language readability.  The keywords
  346.         CALC, EVAL, WHAT, and CASE all do the same thing.
  347.  
  348.         If you want to use arithmetic (+-/*^<> or =) to evaluate an
  349.         expression you must tell BozoL to do so.  For example, if you
  350.         wanted to print 1+1, you must say
  351.  
  352.                 PRINT CALC 1+1
  353.  
  354.         you could also say
  355.  
  356.                 PRINT EVAL 1+1  or PRINT WHAT 1+1 or PRINT CASE 1+1
  357.  
  358.         in which case BozoL would print the number 2 on the screen.  If
  359.         you were to say
  360.  
  361.                 PRINT 1+1
  362.  
  363.         then BozoL would print "1+1" on the screen.  The reason for doing
  364.         it this way greatly increases the speed of the interpreter.  It
  365.         also greatly reduces its complexity.
  366.  
  367.         Again, having four synonyms for CALC may seem unnecessary but they
  368.         come in handy when writing different kinds of statements.  For
  369.         example you could use the dummy word IS to make a statment that
  370.         goes like this
  371.  
  372.                 PRINT WHAT 1+1 IS
  373.  
  374.         or you could make your source code more readable by using CASE
  375.         in conjunction with the IF statement, like
  376.  
  377.                 IF CASE A=B: PRINT "They Match"
  378.  
  379.         Program Logic
  380.  
  381.         BozoL features the statements IF, WHILE, and UNTIL to embody its
  382.         logic.  You can add others if you like.  It's easy.
  383.  
  384.         When a WHILE or UNTIL statement is executed, the expression which
  385.         follows it is immediately evaluated.  If the expression is true,
  386.         UNTIL will cause BozoL to immediately abort the current line and
  387.         go on to the next one, or end the program if there are no more
  388.         statements.  WHILE is the exact opposite of UNTIL.  For example,
  389.  
  390.                 PRINT "Hi There!" UNTIL LEN INKEY
  391.  
  392.         This statement will print "Hi There!" over and over again on the
  393.         screen until the function INKEY returns something with a length.
  394.         That is, until a key is pressed.
  395.  
  396.                 PRINT "Hi There!" WHILE NOT LEN INKEY
  397.  
  398.         will do the same thing.  As long as the expression remains true,
  399.         WHILE and UNTIL will continue to execute the entire line over
  400.         and over again.
  401.  
  402.         IF is similar.  When BozoL gets to the IF, the expression following
  403.         IF will be evaluated.  If the expression returns a non-zero value,
  404.         the remainder of the line will be executed.  If you are using
  405.         colons to delimit the individual statements on the line, this
  406.         means the remainder of the line following the IF statement.  If
  407.         you are not using colons to delimit the statements on the line
  408.         this refers to the statements which preceed the IF statements.
  409.  
  410.         In other words, the statement
  411.  
  412.                 IF EVAL A=B: PRINT "They Match"
  413.  
  414.         Will print "They Match" on the screen if A is equal to B.  Also,
  415.         the line
  416.  
  417.                 PRINT "They Match" IF EVAL A=B
  418.  
  419.         will do the same thing.
  420.  
  421.         Program flow control
  422.  
  423.         All of the program flow control in native BozoL is contained within
  424.         the simple GOTO and GOSUB...RETURN command sets.  At any point in
  425.         your program you may include a label which is on a line by itself
  426.         and is not a BozoL keyword.  Labels can be any word or words as long
  427.         as they are unique.  To jump to a label, just say GOTO ABC, where
  428.         ABC would be the label name.
  429.  
  430.         GOSUB works the same way, except BozoL remembers the line number
  431.         where you GOSUBed from.  At any later point you may execute a
  432.         RETURN statement and BozoL will resume program execution at the
  433.         next line following the GOSUB, unlike BASIC which will resume
  434.         execution at the next statement, which may be on the same line.
  435.  
  436.         You can GOSUB up to 32 times until you must return.  If you try
  437.         to GOSUB more than 32 times without ever returning BozoL will
  438.         give you an overflow error.  You can increase the size of the
  439.         GOSUB stack by modifying the source code, although it will
  440.         probably never be necessary.
  441.  
  442.         You can also GOTO or GOSUB to a line number, but this is not
  443.         advisable.  If you write BozoL programs in a text editor you
  444.         must not include line numbers.  If you have a GOTO 10 in your
  445.         program and then insert a line before line 10, GOTO 10 will
  446.         then go to the wrong line.
  447.  
  448.         Finally, you may GOTO or GOSUB to a line number which is
  449.         contained in a variable.  For example, you could say
  450.  
  451.                 SET A TO 100
  452.                 GOTO A
  453.  
  454.  
  455.         4. HOW TO ADD COMMANDS AND FUNCTIONS
  456.  
  457.  
  458.         BozoL is kind of useless unless you intend to add your own
  459.         custom commands and functions.  That is, after all, the whole
  460.         point to having an interpreted language written in PowerBASIC.
  461.  
  462.         Adding commands and functions is easy.  You must be aware of
  463.         the difference between a command and a function.  A command
  464.         is a keyword which actually does something, like PRINT or
  465.         INPUT or LAUNCH THE MISSILES.  A function is a keyword which
  466.         may have parameters, operate on those parameters, and then
  467.         leave behind a return value to be acted on by another function
  468.         or a command.
  469.  
  470.         For example, CHR is a function.  CHR does not execute anything,
  471.         rather, it looks at the parameter which follows it and pushes
  472.         a new parameter onto the stack.
  473.  
  474.                 CHR 1
  475.  
  476.         This will do nothing.
  477.  
  478.                 PRINT CHR 1
  479.  
  480.         BozoL will look at the 1 and push it onto a special stack.  Then
  481.         it will look at CHR.  CHR will read the 1 off of the stack and
  482.         push a happy face back onto the stack.  PRINT will then see the
  483.         happy face on the stack and print it.
  484.  
  485.         Read that paragraph again and again if you didn't understand it.
  486.         It can take a while to sink in if you're not familiar with the
  487.         concepts.
  488.  
  489.         To add a custom keyword you first need to think up a name for
  490.         the keyword, and then what it does.  Gee, that's kind of like
  491.         creating a new SUB or FUNCTION in PowerBASIC, isn't it?  It
  492.         is very similar.
  493.  
  494.         Lets start with an example.  BozoL does not have a NEW command,
  495.         which would erase the current program in memory and stop
  496.         execution.  Adding NEW to BozoL is easy.
  497.  
  498.         All of the commands in BozoL are broken up into a handful of
  499.         include files which have a .CMD extension.  These include
  500.         LOGIC.CMD, which contains IF, WHILE, and UNTIL, FUNCTION.CMD
  501.         which contains many rudamentary functions like ASC, CHR,
  502.         UCASE, LEFT, RIGHT, and MID, and others.
  503.  
  504.         LOAD, RUN, and other related commands are in the include file
  505.         LOADRUN.CMD.  If you look at this file you can see where the
  506.         guts of these commands are defined.  Each commands starts out
  507.         with a CASE statement (remember, we are in PowerBASIC now).
  508.  
  509.         These files are included in the middle of a big SELECT CASE
  510.         loop which is in the subroutine EXEC in the file BOZOL.BAS.
  511.         If you look at this file and sub you can see where all of the
  512.         *.CMD files are included.
  513.  
  514.         NEW would belong with the other commands in LOADRUN.CMD, although,
  515.         of course, you could put them anywhere.  Pull LOADRUN.CMD up into
  516.         the PowerBASIC editor and page down to the end of the file.
  517.  
  518.         Add a new item to this CASE structure.  Add a few spaces to the
  519.         end of the file and type in the line
  520.  
  521.                 CASE "NEW"
  522.  
  523.         This officially defines a new command in the BozoL language.  Now
  524.         all you need to do is enter some code to carry out what you want
  525.         the NEW command to do.  We want to erase the program and stop
  526.         execution of the program.  The program is stored in a shared array
  527.         called PROGRAM$(), so the next line would be this:
  528.  
  529.                 REDIM PROGRAM$(1000)
  530.  
  531.         This would effectively erase the contents of the program array.
  532.         Next you need to make sure the program stops.  BozoL thinks
  533.         that the program is running as long as the shared variable
  534.         PROG% is true.  Add the statement
  535.  
  536.                 PROG%=0
  537.  
  538.         Now all you need to do is recompile BOZOL.BAS.  Try it out!
  539.         Enter a small program and type LIST.  Then type NEW.  Then
  540.         type LIST.  Voila!  It's gone!  You just added a new command
  541.         to BozoL!
  542.  
  543.         Commands that use arguments
  544.  
  545.         By the time BozoL gets to a command, all possible arguments are
  546.         on a special stack called the Argument Stack.  This is actually
  547.         a string array that can store up to 16 arguments at a time.  Since
  548.         mose functions and commands only require one or two arguments this
  549.         is quite adequate.
  550.  
  551.         You can ask for these arguments one at a time by using the
  552.         PowerBASIC function POPARG$.  For example, the print command
  553.         keeps printing whatever is returned by POPARG$ until it runs
  554.         out of arguments.  The shared variable ArgPtr% contains the
  555.         number of arguments currently on the stack.  You may find this
  556.         variable useful if you want to create commands and functions that
  557.         accept a variable number of arguments.
  558.  
  559.         Lets try adding a new command.  Fund the place in BOZOL.BAS
  560.         where all of the *.CMD files are included.  Add a new include
  561.         file called "CUSTOM.CMD"
  562.  
  563.         Next, create CUSTOM.CMD.
  564.  
  565.         The first line of CUSTOM.CMD should be CASE something, where
  566.         something is the new command you want to add.  Lets add a
  567.         special purpose function which returns the entire contents of
  568.         a file.  this function does not really do anything by itself,
  569.         but it will be a keyword you can use in other expressions.
  570.  
  571.                 CASE "GETFILE"
  572.                         Buf% = FREEFILE
  573.                         OPEN POPARG$ FOR BINARY AS #Buf%
  574.                         GET #Buf%, LOF(Buf%), A$
  575.                         PUSHARG A$
  576.                         CLOSE #Buf%
  577.  
  578.         After you have added these lines, recompile BozoL and run it.
  579.         Try out this new command by typing in this direct statement
  580.  
  581.                 PRINT GETFILE "\AUTOEXEC.BAT"
  582.  
  583.         Your whole AUTOEXEC.BAT file should print out on the screen!
  584.  
  585.         Notice that we used POPARG and PUSHARG to manipulate the BozoL
  586.         argument stack.  We didn't want to print "GETFILE", we wanted
  587.         GETFILE to literally return the entire contents of a file,
  588.         so use used POPARG$ to find out what file name followed the
  589.         GETFILE keyword, opened the file, read the whole file into a
  590.         single variable, and then pushed the whole file onto the argument
  591.         stack.  Then PRINT looked at the argument stack to see what was
  592.         there and finds the entire contents of your AUTOEXEC.BAT.  PRINT
  593.         then prints it on the screen.
  594.  
  595.  
  596.         5. CALLING BOZOL FROM YOUR OWN PROGRAMS
  597.  
  598.         In addition to being able to custom the language, you will also
  599.         want to call the BozoL interpreter from your own programs.  BozoL
  600.         requires the DIM and SHARED statements which exist at the top of
  601.         BOZOL.BAS to be already defined in your own program.  Once you
  602.         have done this all you need to do is call the subroutine PROGRUN.
  603.         PROGRUN requires an array as a parameter, preferably PROGRAM$(),
  604.         although you can pass it any other string array if you like.  You
  605.         must also specify whether or not you want BozoL to actually start
  606.         running the program in PROGRAM$ or to display a command prompt
  607.         and wait for someone to type RUN.  This is done by placing a
  608.         true or false value into the shared variable PROG%. If PROG% is
  609.         true then the program will run.  If it is false then PROGRUN
  610.         will just display an OK prompt and wait for a command to be
  611.         entered at the keyboard.  If you simply want to invoke the
  612.         interpeter, just call PROGRUN with prog% set to 0.
  613.  
  614.         If the program contained in PROGRAM$ ends without and explicit
  615.         END or QUIT statement, the user will be returned to a command
  616.         prompt.  END or QUIT exits the PROGRUN sub completely, returning
  617.         control to your program, or to DOS, depending on how you may
  618.         have it set up
  619.