PASS ...
Posted in 1999
Topics: General Discussion
I`m interesting in how to pass parameter from command line to 4ge module, and how to manage it?? How to transfer parameter`s (or variable) from 4ge module to another 4ge module?
In article <37A6DF95.C8D79EB7@eunet.yu>, INKO <inko@eunet.yu> writes >I`m interesting in how to pass parameter from command line to 4ge >module, and how to manage it?? The function NUM_ARGS() returns the number of arguments passed to the program from the command line. The function ARG_VAL(n) will return the value of the nth argument. >How to transfer parameter`s (or variable) from 4ge module to another 4ge >module? > Am I mis-reading this or is this actually asking how to call functions? Oh well, here goes ... To pass argument 'b' to the function and return argument 'a' from the function use the following syntax when calling the function. LET a = function_name (b) The function is then defined as follows FUNCTION function_name (x) DEFINE x SMALLINT DEFINE y SMALLINT . . . RETURN y END FUNCTION During the call of the function, the variable 'x' is loaded with the value from 'b'. At the end of the function the variable 'a' is loaded with the value from 'y'. If you wish to pass multiple arguments into a function then call it as follows LET a = function_name (b,c) and then define the function as FUNCTION function_name (x, y) DEFINE x SMALLINT, y SMALLINT DEFINE z SMALLINT . . . RETURN z END FUNCTION If you wish to return multiple values then call the function as follows CALL function_name (a) RETURNING b, c and define the function as FUNCTION function_name (x) DEFINE x SMALLINT DEFINE y SMALLINT, z SMALLINT . . . RETURN y, z END FUNCTION If your function does not return a value then you can call it as follows CALL function_name(a) As all function names have to be unique with an executable, the call of the function can be in a different module to the definition of the function. We always start the function name with the name of the module it resides in. Thus when an executable consists of a dozen or so linked modules it is easy to locate the source of any function that is called. -- Steve Wright