![]() ![]() ![]() ![]() | Table Of Contents | Index |
Example:Whenever we use the word SelectFile in the menu, all the lines of the procedure SelectFile will execute.
Procedure SelectFile BoxHeaderColor ForeColor BackColor BoxBorderColor Cyan Mag BoxInsideColor Yellow Mag InverseColor Yellow Red Return PickFile (FileType,4,5,17) EndProc
Parameters can be passed to procedures. When a parameter is passed it is normally passed by value. This mean that a copy of the original is passed. Whatever you do to the copy doesn't affect the original value.
Example:In the above example Square (A) will write 36 but Writeln A will write 6. The reason is that Square passes a copy of A to X but the value of X is not returned to A. If you want the original A to be affected you would use the Loc command.
var A Procedure Square (X) X = X * X Writeln X EndProcA = 6 Square (A) ;prints 36 Writeln A ;prints 6
A = 6 Square (Loc A) ;prints 36 Writeln A ;prints 36In this example we pass Loc A to the Square procedure. Thus, instead of X being set to 6, X is set to point to A. As a pointer, any operation performed on X is performed on A instead.
You can also return parameters from procedures using the Return command.
Example:In MarxMenu you can return any number of parameters as long as the calling procedure is expecting the same number of parameters.
Procedure Cube (X) Return X * X * X EndProcWriteln Cube(3) ;returns 27
Example:In the above example, GotoXY expects two parameters. CenterOfScreen returns two parameters so MarxMenu is happy with it.
Procedure CenterOfScreen Return (ScreenWidth / 2) (ScreenHeight / 2) EndProcGotoXY(CenterOfScreen)
You can pass many parameters and have them concatinated into a single string as the real parameter, much the way the parameters of the Writeln command work. Numbers passed are converted to strings.
When you define your procedure, if you have a single parameter whose name begins with a "$", MarxMenu will process all parameters passed as a single string.
Example:In the above example, because WriteALine had the parameter $Line, it tells MarxMenu to concatinate all parameters passed to it into a single string and put it into the variable Line.
Procedure WriteALine ($Line) FileWriteln(OutputFile,Line) EndProc
WriteALine DateString ' ' TimeString ' ' Temperature
See Also: | EndProc | Return | Loc | ParamsToArray |
---|
Category: | Misc |
---|
![]() ![]() ![]() ![]() | Table Of Contents | Index |
|