Evaluates an ObjectScript function at compile time.
This macro preprocessor function evaluates an ObjectScript function at compile time. It has the form
where content is an ObjectScript function and can be user-defined. ##function replaces ##function(content) with the returned value from the function.
The following example returns the value from an ObjectScript function:
#define alphalen ##function($LENGTH("abcdefghijklmnopqrstuvwxyz"))
In the following example, suppose there is a user-defined function in the GetCurrentTime.mac file:
SET ^x = """" _ $Horolog _ """"
It is then possible to invoke this code in a separate routine, called ShowTimeStamps.mac, as follows:
#define CompiletimeTimeStamp ##function($$Tag1^GetCurrentTime())
#define RuntimeTimeStamp $$Tag1^GetCurrentTime()
The output of this at the Terminal is something like:
where the first line of output is the value of $Horolog at compile time and the second line is the value of $Horolog at runtime. (The first line of output is not quoted and the second line is quoted because x substitutes a quoted string for its value, so there are no quotes displayed in the Terminal, while y prints the quoted string directly to the Terminal.)
It is the responsibility of the application programmer to make sure that the return value of the ##function call makes both semantic and syntactic sense, given the context of the call.