You can define functions and macros for use in QA Build formulas. These consist of a name and associated text. The text is evaluated as a macro wherever the name is specified in a formula. In the following example, a mathematical function POWER has been defined which takes one parameter:
Function/Macro name POWER
Function/Macro text
exp(log(%1)*(%2)) {returns first parameter raised to power of second parameter}
A function like the one above can be called in any QA Build formula:
POWER($, 2)
This will evaluate to the value of the current field raised to the power of 2, that is, squared.
The rules for defining functions are:
To define a QA Build function or macro:
The formulas you define in this way are evaluated as your program is compiled. If there are any syntax errors, these will be shown as occurring in the formula in which the function is used.
To use a function:
In the position in the formula where you wish to use the function, enter the name of the function, followed by brackets, and pass the parameters you wish to pass to the function
| Example Macros: | Text: | Comments: |
|---|---|---|
|
TIME_TO_NUMBER |
HOUR(%1)*3600 + MINS(%1)*60 + SECS(%1)
|
This function returns the number of seconds since midnight for any given time
|
|
NUMBER_TO_TIME |
(((00:00 SETHOUR((%1)/3600)) SETMINUTE(((%1)MOD3600)/60))
SETSECOND((%1) MOD 60))
|
This function converts a number to a time, provided that the number means the number of seconds since midnight |
|
TIME_PLUS_NUMBER |
NUMBER_TO_TIME(TIME_TO_NUMBER(%1)+%2)
|
This function uses the two functions defined above to add a number representing the number of seconds since midnight to a time |
For the benefits of using macros see Macro Formulas .