
 *************************************************************************

                   [42mA GUIDE TO AMOS 6 - MORE ON PROCEDURES[0m

                               [3m[1mBY BRUCE LAING[0m

             [33m© 1994 Bruce Laing for Megadisc Digital Publishing[0m

  *************************************************************************


    Easy AMOS users please see the Errata at the bottom of this file! -S


         [32m43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43[0m


   Welcome to part 6 of the "guide to AMOS" series.  In this article, I
  will be concluding our look at procedures as well as having a look at
  the more advanced structured commands available in AMOS professional.


   In the previous Megadisc, i showed you two ways of passing variables
  into procedures from the main program.  As i mentioned, there are ways
  of passing variables to procedures, and the third is to enclose the
  variables in square brackets in the Procedure statement.

  E.G.

  A=1 : B=2
  PR[A,B]
  Procedure PR[A,B]
  Print A,B
  End Proc

   What if you wish to pass variables back to the main program from the
  original procedure?  you can do this using a modified version of the End
  Proc command as well as the param function.  First i will explain the
  modified End Proc command.  this has the same function as the procedure
  command.  That is:

  End Proc[A,B]

   but for the command to have any use, we must use the param function.
  This has three versions of the same command.  and these are:

  Param (for interger variables)
  Param$ (for string variables)
  Param# (for floating point [or real] numbers)

  Below is an example:

  A=5
  _MUL[A]
  Print Param
  Procedure _MUL[A]
  A=A*5
  End Proc _MUL[A]

  What if you don't wish to let the procedure do it's full course?  You
  can get out of it by using the Pop Proc command.  this command will exit
  back to your main program without going through the full routine.
  Here's a quick example:

  Procedure _GET_OUT
  Main:
  CT=CT+1
  If CT=10 then Pop Proc
  Print "I'm Stuck!"
  goto MAIN
  End Proc


[3m  IS IT OR ISNT IT?[0m

   Previously, i started to talk about the IF/THEN/ELSE/ENDIF structure.
  The If function tests to see if a condition is met.  if the condition is
  met, the command after the THEN statement will be executed.  If the
  condition fails, it will go to the next line.  The Else command simplify
  things.  Take a look at the listing below.....

  A=Rnd(2)
  If A=2 Then Goto _NEXT
  Print "A is less than 2"
  _NEXT:
  program continues.....

   Compare that to the next listing......

  A=Rnd(2)
  If A=2 Then Goto _NEXT : Else Print "A is Less than 2"
  ...
  .....
  _NEXT:
  Program continues.....

   However, there is a slightly different structure using the ENDIF
  statement.  The difference will be that the THEN cannot be used in a
  If/End If combination.

  A=Rnd(2)
  If A=1
   Goto _NEXT
   Else
   Print "A is less than 2"
  End If

  AMOS Professional users have an additional string to their programming
  bow.  This command is called the Else If command, and allows you to have
  multiple tests.

  Take a look at the listing below....

  If A=1
   Print "one"
  Else If A=2
   Print "Two"
  Else
   Print "Three
  End If

  ON ..... PROC COMMAND

   We can simplify the above listings much easier by using the ON command.
   This can have a number of formats.  The possible combinations are:

  On <variable> Goto line1,line2,line3 (for the goto command)
  On <Variable> Gosub line1,line2,line3 (for the Gosub command)

  and of course...

  On <Variable> Proc Proc1,proc2,proc3 (for procedures)

  The above commands are the equivalent of the If/Then commands earlier.
  The only thing you cannot do is check for negative values.  This will
  cause an error.  If the value is higher than the listing in the On...
  command, it will then jump straight to the next line.  for example, if
  the variable A has a value of 4 and you only had three options in the
  On..... command, it would then jump straight to the next line in the
  program.


  Every little thing that you do.....

  Kate Ceberano, 1991


  Here's something if you wish to run a procedure (or subroutine) every
  few 50ths of a second. (or if you live in America, 60ths of a second).
  This command is called the EVERY command.  This command can either be
  used for procedures or subroutines.  All you have to do is to specify
  the length of time between every call in either 50ths (or 60ths) of a
  second.  The thing is you must complete the routine before the specified
  interval time, otherwise an error will be called.  While the routine is
  being called, the EVERY system is disabled automatically.  So if you
  wish to call the routine continuously, you must insert an Every On
  command before the final End Proc (or return) is called.

  Take a look at this quick example:

  Every 50 Proc TEST
  Do
   Print At(0,0);"Loop"
  Loop
  Procedure TEST
   Shared A
   Inc A:Print :This is call number";A
  Every On
  End Proc


[33m  AND NOW... THE END OF THIS ARTICLE[0m

   This marks the end of this editions article.  you will find on this
  disk a short example program explaining most of the commands mentioned
  in this article.  In the next MD, I will have a look at some of the
  excellent extensions available.  The article will include a quick
  tutorial on the CText extension, as well as the excellent music
  extension EME (the enhanced music extension) and explain the new (and
  modified) commands in this extension.

  So Until next time

  BCNU

                               © Bruce Laing,

                               December, 1994



          [32m-  =  -  =  -  =  -  =  -  =  -  =  -  =  -  =  -  =  -
[0m

                             [42mERRATA for routine[0m

  Easy AMOS users, please note that the EVERY command is not implimented
  in your version.  You will have to rem out the procedure in the listing,
  otherwise, a "Command not available in Easy AMOS" error will rear its
  ugly head.  Sorry.


                                   [1mBruce,[0m

                               December, 1994



         [32m43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43  !¡  43[0m


