[comp.sys.atari.st] OSS Personal Pascal article #1

DAVIDLI@simvax.BITNET (12/24/86)

Date:     Tue, 23 Dec 86 20:13 CST
From:     <DAVIDLI@SIMVAX.BITNET> (System Manager)
Subject:  OSS Personal Pascal article #1
To:       info-atari16@score.stanford.edu
X-Original-To:  info-atari16@score.stanford.edu, DAVIDLI

Here is the first of two articles I have written about OSS Personal
Pascal.  Pass it along to your user groups, whatever.




                                Now What?
                   OSS Personal Pascal and the Beginner
                          written by David Meile

     [Copyright 1986 David Meile, all rights reserved.  Permission is
     given to Atari user groups to reprint this article, as long as
     this statement is included.  OSS Personal Pascal is a product of
     Optimized Systems Software, Inc.  I am not related to the company,
     I simply bought their compiler.]

                              Your first program

        Ok, so now you own a copy of OSS Personal Pascal.  You're
     sitting there at you ST, book in hand, trying to figure out just
     what you should be doing now that you have a REAL programming
     language.  And it's a compiler, and it uses GEM and it looks
     neat ...
        Now what?

        Most computer languages give you a basic introduction to the
     simplicity and ease of [C, BASIC, LOGO, Pascal, LISP ...] using
     a program that dates from year 1 -- printing HELLO on the screen.
     OSS has even included such a program FOR you!  But, you want to
     do something different, something with GEM ...
        OK.  The easiest thing to do using Personal Pascal is a GEM
     program that produces an ALERT BOX on your screen.  It introduces
     you to the basic structure of a Pascal program for the ST, and
     also allows you to get a feel for the amount of time it's going
     to take you to compile and link all of your other brilliant
     creations.
        An ALERT BOX tells the computer user something useful, such
     as the fact that you're in the wrong resolution to run a graphics
     program.  It waits around until you've read the message and
     responded by pressing the mouse button while pointing at a box
     conveniently provided for that purpose.  There are other uses for
     this box that I'll let you create for yourselves.

        So, the first step to writing this brilliant program is to enter
     the editor and type the following program.  Incidentally, if you
     have enough memory for a RAM disk, it will be MUCH faster to copy
     the OSS Pascal files to the RAM disk and run them from there.  I'll
     mention some ways to do this (and list public domain sources for
     them) in my next (?) article.

        IF YOU HAVE NEVER USED THE OSS PERSONAL PASCAL EDITOR, PLEASE
     NOTE!!  There is a section on using the editor in your manual.
     READ it!  It takes a while to get used to it.  About the only
     thing I want you to realize right now is that when it asks you
     for a file name, enter one!  I haven't found any way to save a
     file if the file name wasn't previously entered.  [And it caused
     me much grief too...]  Remember, the editor should be accessed from
     the Personal Pascal desktop, which means you have to run PASCAL.PRG
     from the GEM desktop.

                      Here is the program I typed in
                      ------------------------------

     PROGRAM first;

     { Make use of the GEM calls to provide a simple Alert Box }

       CONST
         {$I GEMCONST.PAS}

       TYPE
         {$I GEMTYPE.PAS}

       VAR
         Choice : integer;

       {$I GEMSUBS.PAS}

       BEGIN
         If Init_Gem >= 0 THEN
           BEGIN
             Choice := Do_Alert('[2][Now what?][ End ]',0);
             Exit_Gem;
           END;
       END.

        Big program, huh?  The '{$I ...' tells Personal Pascal that I
     want to use some GEM stuff that OSS has supplied to make things
     easy.  The 'Init_Gem' function asks the operating system to set
     things up so I can run a GEM program, and if not, exits.  The
     'Exit_Gem' function returns control back to the operating system,
     which usually means "back to the desktop".
        My alert box is created by the function Do_Alert.
        What's a function?  A function is a sub-program that takes
     parameters and gives back a value.  In this case, Do_Alert returns
     an 'integer' value, and the variable 'Choice' has been declared an
     integer.  Integers are whole numbers:  -33, -5, 0, 666, 42, etc.
        Do_Alert has TWO parameters, and they are separated by commas
     within that set of () in the program.  The first parameter is a
     STRING value.  In Pascal, strings are enclosed by a single quote,
     ('This is a Pascal string, there are single quotes') much as strings
     are enclosed by double quotes in BASIC.
        There are three PARTS to that string value however, and each is
     enclosed by brackets [].
        The first part tells what kind of ICON should be included in the
     alert box.  Icons are little pictures -- like your disk drives and
     the trash can on the ST desktop.  In this case, the [2] indicates
     I want a Question Mark in my alert box.
        The second part tells what message I want included.  You can
     have as many as five lines (ok, five *SHORT* lines) in your alert
     box, separated by vertical bars [ line 1 | line2 ] between lines.
     But remember, simplicity is the key word here.  Make it short
     and sweet.  My message is, of course, [Now What?]
        The third part tells what sort of 'button name' I want.  You
     can include up to three names, again separated by vertical bars.
     It helps if you put spaces around the words, so that the little
     boxes that get created look neat.  I wanted mine to indicate the
     end of the program, so my 'button name' is [ End ] (notice the
     extra space..).
        The other parameter (remember, after the comma?) tells
     which choice you want to be the default.  This lets you press the
     RETURN key rather than clicking the mouse, and returns a default
     VALUE (remember, Choice is an integer).  I didn't need a default,
     so I used the number 0.  If you use 1, 2, or 3 then the associated
     'button name' gets surrounded by a darker border than the others.
     Oh yes, using a 0 means that you can't just press the RETURN key,
     you have to 'point-and-click'.
        That's about it for this program.  It starts up GEM, draws the
     alert box, waits for the mouse point-and-click, and exits the
     program.  I'm sure you can think of equally useful things to do
     with alert boxes in YOUR programs.

                     Now ... let's compile this thing

        You've typed in a program (any program..).  You want to save it
     and compile it and link it and run it and go on to bigger and better
     things.  There are two ways to do this:

     1.  Exit (save) and compile and link the program.  The all purpose
         function key F9 will do this for you.  Go ahead.  Try it.
         Just be sure that your OSS Personal Pascal disk is in one of
         the drives (or RAM disk).  By the way -- you ARE using a backup
         copy of your OSS Personal Pascal disk, right?

     2.  Save and exit the editor.  It's as easy as pressing the F10
         function key on your ST.  Take a break and compile the program
         later, or whatever.

        For this masterpiece, use the F9 key.  Take a peek at the second
     hand of any available clock and start counting.
        Your program is saved, then the compiler is loaded, then your
     program is loaded, then the 'include' files are loaded and
     everything is compiled.  Your disk drive(s) should be going almost
     constantly.  If there are no typing errors the compiled program is
     saved, then the linker is loaded, then your compiled 'object' code
     (what the compiler puts out) is loaded then several GEM libraries
     are loaded and linked and your finished program is saved to disk.
        OK.  Note where the clock's second hand is now.  That's how long
     it takes to compile and link a short Pascal program.  As I mentioned
     before, this time can be shortened a *lot* by loading your OSS
     Personal Pascal program files to a RAM disk before you begin.
     (Lightening speed ... but the disk drive still goes constantly, as
     your program is read-compiled-saved and read-linked-saved).

                            Now for the final step ...

        Your program compiled and linked with no errors this time!
     Great!  To see your masterpiece, you can exit the Pascal desktop
     and go back to good 'ol GEM OR you can use the RUN option on the
     Pascal menu.  Try either one.  Step back and admire, then point-
     and-click to get rid of the alert box.  Congratulations!

                              Next time (?)

        If I get some positive feedback, I'll continue with this series
     and start to delve into the simpler aspects of learning just how
     to do things in Personal Pascal.  For starters, I'll work with a
     program that actually draws a LINE on the screen!!
        I'm also open to answering some SIMPLE questions regarding
     Personal Pascal. You can reach me via GEnie as D.MEILE, or
     write (include a stamp, please) to:

               David Meile
               Box 13038 - Dinkytown Station
               Minneapolis, MN  55414

                            Additional reading


        If you know absolutely nothing about the Pascal language, may
     I recommend the following book to you?

     Programming for People/Pascal  by  David G. Kay
     -----------------------------

        Mayfield Publishing Company, Palo Alto, CA. 1985. About $20.00.

-----------------------------

BITNET address:         davidli@simvax.BITNET
USENET address:         ihnp4!mmm!umn-cs!simvax!davidli