Passing Calling Parameters
to an Ultra-SiMPLE Program
Just as in the case of tasks and functions, Ultra-SiMPLE programs can also have calling parameters passed to them.
The Ultra-SiMPLE system library contains an Int function named Numargs() and a Text function named Param(). The Ultra-SiMPLE program's first calling parameter is returned by Param(1), the second by Param(2), etc. The number of parameters that have been passed to the Ultra-SiMPLE program is returned by the Numargs() function.
When the Ultra-SiMPLE program has been compiled and is ready for use, the user simply types the name of the program onto the command line, followed by the sequence of calling parameters separated by spaces.
As a simple illustration of these ideas, consider the following program (which we will name "DRAW"):
Ultra-SiMPLE If (Numargs()!=2) quit If (Param (1)~"red") solid color (4) If (Param (1)~"green") solid color (2) If (Param (1)~"blue") solid color (1) If (Param (2)~"square") solid rectangle (300, 220, 340, 260) If (Param (2)~"circle") solid circle (320, 240, 25) tab xy (27, 10) Display "You asked for a",,Param(1),,Param(2)
When you run the program (by typing RUN DRAW on the command line), the program does nothing (because no calling parameters have been specified). But now type:
DRAW RED CIRCLE
on the command line. Presto! The program draws a red circle. And if you type:
DRAW GREEN SQUARE
on the command line, the program draws a green square. (Go ahead and try all the other combinations of the three colors: RED, GREEN, and BLUE, along with the two shapes: CIRCLE and SQUARE.)
[
Webmaster |
FAQ's |
Home Page |
Contact Us ]