|
|||||
Functions | |||||
Related Syntax |
If you have a piece of code that you want to execute repeatedly in a program, you might want to define that code as a function. One property of functions is that they are encapsulations of code that can be "called" or executed from another point in a program. For example, you could define a function that issues error messages out to a file:
define function Report value stream msg as reopen log-file as file "MyProgram.log" put log-file date "xY/M/D h:m:s" || " MyProgram: %g(msg)%n" close log-file
It is possible to define functions that return numeric, string, or Boolean values using the counter
, stream
, and switch
keywords, and you can also define functions that don't return values. A function name can be anything you want it to be, as long as it is a single string of characters. For example, "add_total", "do-this", or "MacBeth" could all be function names.
In the function shown above there is only one argument, "stream msg".
Related Syntax define function HttpResponseOutput |
---- |