Identifiers

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


This section describes the conventions for naming various objects in the 4th Dimension language. The names for all objects follow these rules:

A name must begin with an alphabetic character.

Thereafter, the name can include alphabetic characters, numeric characters, the space character, and the underscore character.

Periods, slashes, and colons are not allowed.

Characters reserved for use as operators, such as * and +, are not allowed.

4th Dimension ignores any trailing spaces.

Tables


You denote a table by placing its name between brackets: [...]. A table name can contain up to 31 characters.

Examples

   DEFAULT TABLE ([Orders])
   INPUT FORM ([Clients]; "Entry")
   ADD RECORD ([Letters])

Fields


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.

Do not start a field name with the underscore character (_). The underscore character is reserved for plug-ins. When 4th Dimension encounters this character at the beginning of a field in the Method editor, it removes the underscore.

Examples

   [Orders]Total:=Sum([Line]Amount)
   QUERY([Clients];[Clients]Name="Smith")
   [Letters]Text:=Capitalize text ([Letters]Text)

It is a good programming technique to specify the table name before the field, even though it is not absolutely necessary in a table, form, or object method.

Subtables


You denote a subtable by first specifying the parent table to which the subtable belongs. The subtable name immediately follows the table name. A subtable name can contain up to 31 characters.

Examples

   ALL SUBRECORDS ([People]Children)
   ADD SUBRECORD ([Clients]Phones;"Add One")
   NEXT SUBRECORD ([Letters]Keywords)

A subtable is treated as a type of field; therefore, it follows the same rules as a field when used in a form. If you are specifying a subtable in the table, form, or object method of the parent table, you do not need to specify the parent table name. However, it is a good programming technique to specify the name of the table before the subtable name.

Subfields


You denote a subfield in the same way as a field. You denote the subfield by first specifying the subtable to which the subfield belongs. The subfield name follows, and is separated from the subtable name by, an apostrophe ('). A subfield name can contain up to 31 characters.

Examples

   [People]Children'First Name:=Uppercase([People]Children'First Name)
   [Clients]Phones'Number:="408 555–1212"
   [Letters]Keywords'Word:=Capitalize text ([Letters]Keywords'Word)

If you are specifying a subfield in a subtable, form, or object method of the subfile, you do not need to specify the subtable name. However it is a good programming technique to specify the table name and the subtable name before the name of the subfield.

Interprocess Variables


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
   <>vsKey:=Char(KeyCode)
   If (<>vtName#"")

Process Variables


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)
   If (bValidate=1)
   vsCurrentName:=""

Local Variables


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)
   If ($vsTempVar="No")
   $vsMyString:="Hello there"

Arrays


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,

 Process arrays,

Local arrays.

Interprocess Arrays

The name of an interprocess array is preceded by 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 array name can contain up to 31 characters, not including the <> symbols.

Examples

   ARRAY TEXT(<>atSubjects;Records in table([Topics]))
   SORT ARRAY (<>asKeywords; >)
   ARRAY INTEGER(<>aiBigArray;10000)

Process Arrays

You denote a process array by using its name (which cannot start with the <> symbols nor the dollar sign $). A process array name can contain up to 31 characters.

Examples

   ARRAY TEXT(atSubjects;Records in table([Topics]))
   SORT ARRAY (asKeywords; >)
   ARRAY INTEGER(aiBigArray;10000)

Local Arrays

The name of a local array is preceded by the dollar sign ($). An local array name can contain up to 31 characters, not including the dollar sign.

Examples

   ARRAY TEXT($atSubjects;Records in table([Topics]))
   SORT ARRAY ($asKeywords; >)
   ARRAY INTEGER($aiBigArray;10000)

Elements of arrays

You reference an element of an interprocess, process or local array by using the curly braces({…}). The element referenced is denoted by a numeric expression.

Examples

      ` Addressing an element of an interprocess array   
   If (<>asKeywords{1}="Stop")
   <>atSubjects{$vlElem}:=[Topics]Subject
   $viNextValue:=<>aiBigArray{Size of array(<>aiBigArray)}

      ` Addressing an element of a process array   
   If (asKeywords{1}="Stop")
   atSubjects{$vlElem}:=[Topics]Subject
   $viNextValue:=aiBigArray{Size of array(aiBigArray)}

      ` Addressing an element of a local array   
   If ($asKeywords{1}="Stop")
   $atSubjects{$vlElem}:=[Topics]Subject
   $viNextValue:=$aiBigArray{Size of array($aiBigArray)}

Elements of two-dimensional arrays

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   
   If (<>asKeywords{$vlNextRow}{1}="Stop")
   <>atSubjects{10}{$vlElem}:=[Topics]Subject
   $viNextValue:=<>aiBigArray{$vlSet}{Size of array(<>aiBigArray{$vlSet})}
      ` Addressing an element of a two-dimensional process array   
   If (asKeywords{$vlNextRow}{1}="Stop")
   atSubjects{10}{$vlElem}:=[Topics]Subject
   $viNextValue:=aiBigArray{$vlSet}{Size of array(aiBigArray{$vlSet})}

      ` Addressing an element of a two-dimensional local array   
   If ($asKeywords{$vlNextRow}{1}="Stop")
   $atSubjects{10}{$vlElem}:=[Topics]Subject
   $viNextValue:=$aiBigArray{$vlSet}{Size of array($aiBigArray{$vlSet})}

Forms


You denote a form by using a string expression that represents its name. A form name can contain up to 31 characters.

Examples

   INPUT FORM([People];"Input")
   OUTPUT FORM([People]; "Output")
   DIALOG([Storage];"Note box"+String($vlStage))

Methods


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)
   DELETE DUPLICATED VALUES
   APPLY TO SELECTION ([Employees];INCREASE SALARIES)

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
   QUERY BY FORMULA ([aTable];Special query)
      ` This command expects a method (procedure) or statement
   APPLY TO SELECTION ([Employees];INCREASE SALARIES)
      ` But this command expects a method name
   ON EVENT CALL ("HANDLE EVENTS")
      ` And this Plug-In command expects a method name
   WR ON ERROR ("WR HANDLE ERRORS")

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
   DROP SPACES (->[People]Name)

      ` Within Calc creator:
      ` - $1 is numeric and equal to 1
      ` - $2 is numeric and equal to 5
      ` - $3 is text or string and equal to "Nice"
      ` - The result value is assigned to $0
   $vsResult:=Calc creator (1; 5; "Nice")

      ` Within Dump:
      ` - The three parameters are text or string
      ` - They can be addressed as $1, $2 or $3
      ` - They can also be addressed as, for instance, ${$vlParam} where $vlParam is 1, 2 or 3
      ` - The result value is assigned to $0
   vtClone:=Dump ("is"; "the"; "it")

Plug-In Commands (External Procedures, Functions and Areas)


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)
   $pvNewArea:=PV New offscreen area

Sets


From the scope point of view, there are two types of sets:

Interprocess sets

Process sets.

4D Server also includes:

Client sets.

Interprocess Sets

A set is an interprocess set if the name of the set is preceded by 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 set name can contain up to 80 characters, not including the <> symbols.

Process Sets

You denote a process set by using a string expression that represents its name (which cannot start with the <> symbols or the dollar sign $). A set name can contain up to 80 characters.

Client Sets

The name of a client set is preceded by the dollar sign ($). A client set name can contain up to 80 characters, not including the dollar sign.

Note: In 4D Client/Server up to version 6, a set was maintained on the Client machine where it was created. Starting with version 6, 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
   USE SET("<>Deleted Records")
   CREATE SET([Customers];"<>Customer Orders")
   If (Records in set("<>Selection"+String($i))>0)
      ` Process sets
   USE SET("Deleted Records")
   CREATE SET([Customers];"Customer Orders")
   If (Records in set("<>Selection"+String($i))>0)
      ` Client sets
   USE SET("$Deleted Records")
   CREATE SET([Customers];"$Customer Orders")
   If (Records in set("$Selection"+String($i))>0)

Named Selections


From the scope point of view, there are two types of named selections:

Interprocess named selections

Process named selections.

Interprocess Named Selections

A named selection is an interprocess named selection if its name is preceded by 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 named selection name can contain up to 80 characters, not including the <> symbols.

Process Named Selections

You denote a process named selection by using a string expression that represents its name (which cannot start with the <> symbols nor the dollar sign $). A named selection name can contain up to 80 characters.

Examples

      ` Interprocess Named Selection
   USE NAMED SELECTION([Customers];"<>ByZipcode")
      ` Process Named Selection
   USE NAMED SELECTION([Customers];"<>ByZipcode")

Processes


In the single-user version, or in Client/Server on the Client side, there are two types of processes:

Global processes

Local processes.

Global Processes

You denote a global process by using a string expression that represents its name (which cannot start with the dollar sign $). A process name can contain up to 31 characters.

Local Processes

You denote a local process if the name of the process is preceded by a dollar ($) sign. The process name can contain up to 31 characters, not including the dollar sign.

Example

      ` Starting the global process "Add Customers"
   $vlProcessID:=New process("P_ADD_CUSTOMERS";48*1024;"Add Customers")
      ` Starting the local process "$Follow Mouse Moves"
   $vlProcessID:=New process("P_MOUSE_SNIFFER";16*1024;"$Follow Mouse Moves")

Summary of Naming Conventions


The following table summarizes 4th Dimension naming conventions.

TypeMax. LengthExample
Table31[Invoices]
Field31[Employees]Last Name
Subtable31[Friends]Kids
Subfield 31[Documents]Keyword'Keyword
Interprocess Variable<> + 31<>vlNextProcessID
Process Variable31vsCurrentName
Local Variable$ + 31$vlLocalCounter
Form31"My Custom Web Input"
Interprocess Array<> + 31<>apTables
Process Array31asGender
Local Array$ + 31$atValues
Method 31M_ADD_CUSTOMERS
Plug-in Routine31WR INSERT TEXT
Interprocess Set<> + 80"<>Records to be Archived"
Process Set80"Current selected records"
Client Set$ + 80"$Previous Subjects"
Named Selection80"Employees A to Z"
Interprocess Named Selection<> + 80"<>Employees Z to A"
Local Process$ + 31"$Follow Events"
Global Process31"P_INVOICES_MODULE"

Resolving Naming Conflicts


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), 4th Dimension 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.

4th Dimension identifies names used in procedures in the following order:

1. Fields

2. Commands

3. Methods

4. Plug-in routines

5. Predefined constants

6. Variables.

For example, 4th Dimension has a built-in command called Date. If you named a method Date, 4th Dimension 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", 4th Dimension would try to use your field instead of the Date command.

See Also

Arrays, Constants, Data Types, Methods, Operators, Pointers, Variables.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next