The registercustomfunction statement defines a new custom function.
Parameters
This statement has four parameters:
folder – This parameter is unused but is retained for compatibility with Panorama 6. You can either set this parameter to ""
or omit it entirely
name – This is the name of the custom function. The name must start with a letter, and then may contain letters, numbers, period, underscore, and the omega symbol (Ω). Upper and lower case are the same (function names are case insensitive). Earlier versions of Panorama required that the function name end with (
, but this is now optional. (Of course the (
is required when using the function.) When choosing a custom function name, make sure you don’t use a name that Panorama is already using – doing so could cause Panorama to break. A good practice is to always prefix your custom function names with a special prefix, perhaps your initials or company name.
parametercount – The number of parameters the function has (0, 1, 2, …).
source – the body of the function. This is the formula that calculates the value returned by the function. If the function has parameters, they must be represented as •1
, •2
, •3
, etc. Note that the entire formula must be quoted.
Description
This statement defines a new custom function. Once a function is defined it remains defined until you quit Panorama, even if the database that originally set up the definition is no longer open.
This example creates a new custom function named concatenate(. This function has two parameters.
registercustomfunction "CONCATENATE(",2,{•1+•2}
Once the function is defined, you can use it in any other formula, just like functions that are built in to Panorama.
Name = concatenate(First,Last)
Starting with Panorama X, you can now define the same function more than once, with different numbers of parameters.
registercustomfunction "CONCATENATE(",2,{•1+•2}
registercustomfunction "CONCATENATE(",3,{•1+•2+•3}
registercustomfunction "CONCATENATE(",4,{•1+•2+•3+•4}
Now you can use this function with different numbers of parameters.
Name = concatenate(First,Last)
Name = concatenate(First,Middle,Last)
Using this technique it’s possible to make the same function do something completely different if it has different numbers of parameters, but we don’t recommend doing that.
A good place to define a custom function is in the .InitializeFunctions
procedure inside a custom statement library (inside the ~/Application Support/PanoramaX/Libraries
folder). If you put your custom function definition code in that procedure, it will run automatically when Panorama starts up, and will also run automatically when you use the Libraries>Register Functions and Statements command in the View Organizer.
See Also
History
Version | Status | Notes |
10.0 | Updated | Carried over from Panorama 6, but now allows the same function to be defined multiple times with different numbers of parameters, and the formula must be quoted. |