4D v13.4Identifiers |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v13.4
Identifiers
Identifiers
This section describes the conventions for naming various objects in the 4D language. The names for all objects follow these rules:
Note: Additional rules need to be respected when objects need to be handled via SQL: only the characters _0123456789abcdefghijklmnopqrstuvwxyz are accepted, and the name must not include any SQL keywords (command, attribute, etc.). The "SQL" area of the Inspector in the Structure editor automatically indicates any unauthorized characters in the name of a table or field. You denote a table by placing its name between brackets: [...]. A table name can contain up to 31 characters. Examples DEFAULT TABLE([Orders]) You denote a field by first specifying the table to which the field belongs. The field name immediately follows the table name. A field name can contain up to 31 characters. Examples [Orders]Total:=Sum([Line]Amount) You denote an interprocess variable by preceding the name of the variable with the symbols (<>) — a “less than” sign followed by a “greater than” sign. Note: This syntax can be used on both Windows and Macintosh. In addition, on Macintosh only, you can use the diamond (Option-Shift-V on US keyboard). An interprocess variable can have up to 31 characters, not including the <> symbols. Examples <>vlProcessID:=Current process You denote a process variable by using its name (which cannot start with the <> symbols nor the dollar sign $). A process variable name can contain up to 31 characters. Examples <>vrGrandTotal:=Sum([Accounts]Amount) You denote a local variable with a dollar sign ($) followed by its name. A local variable name can contain up to 31 characters, not including the dollar sign. Examples For($vlRecord;1;100) You denote an array by using its name, which is the name you passed to the array declaration (such as ARRAY LONGINT) when you created the array. Arrays are variables, and from the scope point of view, like variables, there are three different types of arrays:
Interprocess Arrays Note: This syntax can be used on both Windows and Macintosh. In addition, on Macintosh only, you can use the diamond (Option-Shift-V on US keyboard). An interprocess array name can contain up to 31 characters, not including the <> symbols. Examples ARRAY TEXT(<>atSubjects;Records in table([Topics])) Process Arrays Examples ARRAY TEXT(atSubjects;Records in table([Topics])) Local Arrays Examples ARRAY TEXT($atSubjects;Records in table([Topics])) Elements of arrays Examples ` Addressing an element of an interprocess array Elements of two-dimensional arrays Examples ` Addressing an element of a two-dimensional interprocess array You denote a form by using a string expression that represents its name. A form name can contain up to 31 characters. Examples FORM SET INPUT([People];"Input") You denote a method (procedure and function) by using its name. A method name can contain up to 31 characters. Note: A method that does not return a result is also called a procedure. A method that returns a result is also called a function. Examples If(New client) Tip: It is a good programming technique to adopt the same naming convention as the one used by 4D for built-in commands. Use uppercase characters for naming your methods; however if a method is a function, capitalize the first character of its name. By doing so, when you reopen a database for maintenance after a few months, you will already know if a method returns a result by simply looking at its name in the Explorer window. Note: When you call a method, you just type its name. However, some 4D built-in commands, such as ON EVENT CALL, as well as all the Plug-In commands, expect the name of a method as a string when a method parameter is passed. Example: Examples ` This command expects a method (function) or formula Methods can accept parameters (arguments). The parameters are passed to the method in parentheses, following the name of the method. Each parameter is separated from the next by a semicolon (;). The parameters are available within the called method as consecutively numbered local variables: $1, $2,…, $n. In addition, multiple consecutive (and last) parameters can be addressed with the syntax ${n}where n, numeric expression, is the number of the parameter. Inside a function, the $0 local variable contains the value to be returned. Examples ` Within DROP SPACES $1 is a pointer to the field [People]Name You denote a plug-in command by using its name as defined by the plug-in. A plug-in command name can contain up to 31 characters. Examples WR BACKSPACE(wrArea;0) From the scope point of view, there are two types of sets:
4D Server also includes:
Interprocess Sets Note: This syntax can be used on both Windows and Macintosh. In addition, on Macintosh only, you can use the diamond (Option-Shift-V on US keyboard). An interprocess set name can contain up to 255 characters, not including the <> symbols. Process Sets Client Sets Note: Sets are maintained on the Server machine. In certain cases, for efficiency or special purposes, you may need to work with sets locally on the Client machine. To do so, you use Client sets. Examples ` Interprocess sets From the scope point of view, there are two types of named selections:
Interprocess Named Selections Note: This syntax can be used on both Windows and Macintosh. In addition, on Macintosh only, you can use the diamond (Option-Shift-V on US keyboard). An interprocess named selection name can contain up to 255 characters, not including the <> symbols. Process Named Selections Examples ` Interprocess Named Selection In the single-user version, or in Client/Server on the Client side, there are two types of processes:
Global Processes Local Processes Example ` Starting the global process "Add Customers" The following table summarizes 4D naming conventions.
If a particular object has the same name as another object of a different type (for example, if a field is named Person and a variable is also named Person), 4D uses a priority system to identify the object. It is up to you to ensure that you use unique names for the parts of your database. 4D identifies names used in procedures in the following order: 1. Fields For example, 4D has a built-in command called Date. If you named a method Date, 4D would recognize it as the built-in Date command, and not as your method. This would prevent you from calling your method. If, however, you named a field “Date”, 4D would try to use your field instead of the Date command. |
PROPERTIES
Product: 4D SEE ALSO
Arrays |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||