This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||
|
4D v20 R7
Using tokens in formulas
|
Element | Example (standard syntax) | Suffix | Example (token syntax) | Comments |
4D Command | String(a) | :Cxx | String:C10(a) | xx is the command number |
4D Constant | Pi | :Kxx:yy | Pi:K30:1 | xx is the ID of the constant group and yy is its index (position) within this group |
Table | [Employees] | :xx | [Employees:1] | xx is the table number |
Field | [Employees]Name | :xx | [Employees:1]Name:2 | xx is the field number |
4D Plugin | PV PRINT(area) | :Pxx:yy | PV PRINT:P13000:229(area) | xx is the plug-in ID and yy is the index of the command |
Note: Uppercase letters (C, P) must be used in the suffixes; otherwise, they will not be interpreted correctly.
When you use this syntax, you guarantee that your formulas will be interpreted correctly even in the case of renaming or when the database is executed in a different language.
Note : Constants are also tokenized in the language however in formulas you can just pass their value in order make them independent of the context.
This syntax is accepted in all 4D formulas (or 4D expressions) regardless of the calling context:
The token syntax requires the addition of the reference numbers of various elements. The location of these references depends on the type of element.
Command numbers can be found in this Language Reference manual ("Properties" area) as well as on the Commands page of the Explorer:
Table and field numbers can be obtained using the Table and Field commands.
They are also displayed in the Inspector palette of the Structure editor:
To know what the tokens are for 4D plug-in commands, the trick is to enter the desired code in the Method editor and then restart 4D after disabling the plug-in (for example, by moving its folder). This means that only tokens will be displayed in the Method editor, and you can then copy the ones you need.
Code with plug-in installed:
The same code after plug-in has been disabled:
Product: 4D
Theme: Formulas
4D Language Reference ( 4D v20 R7)