Passing Calling Parameters
to a Pro-SiMPLE Program


Just as in the case of tasks and functions, Pro-SiMPLE programs can also have calling parameters passed to them.

Pro-SiMPLE automatically predefines the Text array, Param[], for passing parameters from the user to the program. Param[1] contains the first input parameter, Param[2] the second, etc. The number of parameters that have been passed is indicated by the container, Numargs. (Both Param[] and Numargs are accessible only from the main program. They cannot be referenced from tasks or functions.) A maximum of nine calling parameters can be passed to a program.

When the 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"):

 Pro-SiMPLE
 If (Numargs!=2) quit
 graph on
 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 ]