4D v16.3Identifiers |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
Identifiers
Identifiers
This section describes the conventions for naming various objects in the 4D language (variables, tables, forms, etc.):
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 designate a table by placing its name between brackets: [...]. A table name can contain up to 31 characters. Examples DEFAULT TABLE([Orders]) You designate a field by first specifying the table to which it 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 designate 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). The name of an interprocess variable can be up to 255 characters(*), not including the <> symbols. (*) 31 characters if the "Save methods as Unicode" compatibility option is deselected. (see Compatibility page) Examples <>vlProcessID:=Current process You designate 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 255 characters(*). (*) 31 characters if the "Save methods as Unicode" is deselected. (see Compatibility page) Examples <>vrGrandTotal:=Sum([Accounts]Amount) You designate a local variable by placing a dollar sign ($) before the variable name. A local variable name can contain up to 255 characters(*), not including the dollar sign. (*) 31 characters if the "Save methods as Unicode" is deselected. (see Compatibility page) Examples For($vlRecord;1;100) You designate an array by using its name, which is the name you pass to an array declaration (such as ARRAY LONGINT) when you create 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 255(*) 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])) (*) 31 characters if the "Save methods as Unicode" option is deselected. (see Compatibility page) Elements of arrays Examples ` Addressing an element of an interprocess array You reference an element of a two-dimensional array by using the curly braces ({…}) twice. The element referenced is denoted by two numeric expressions in two sets of curly braces. Examples ` Addressing an element of a two-dimensional interprocess array When object notation is enabled (see Object Notation), you designate an object attribute (also called object property) by placing a point (".") between the name of the object (or attribute) and the name of the attribute. An attribute name can contain up to 255 characters and is case sensitive. Examples : myObject.myAttribute:="10" Note : Additional rules apply to object attribute names (they must conform to the ECMA Script specification). For more information, see Using object notation (preview). You designate 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 designate a form object by passing its name as a string, preceded by the * parameter. An object name can contain up to 255 bytes. Example : OBJECT SET FONT(*;"Binfo";"Times") See also the Object Properties section. Note: Do not confuse form objects (buttons, list boxes, variables that can be entered, etc.) and objects in the 4D language. 4D language objects are created and manipulated via object notation or dedicated commands. (see Objects (Language)) You designate 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 designate 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 $error:=SMTP_From($smtp_id;"henry@gmail.com") 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.
(*) 31 characters if the "Save methods as Unicode" compatibility option is deselected. (see Compatibility page) Note: If non-Roman characters are used in the names of the identifiers, their maximum size may be smaller. Be sure to use unique names for the different elements in your database. 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. 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.
See also
Arrays
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||