Assignment and punctuation

Assignment is represented with a colon followed by an equal sign, the combination being treated as a single symbol. The evaluated value of the expression, to the right of the assignment symbol, is assigned to the variable on the left side, as shown in the following line of code:

"Phone No." := '312-555-1212';

All statements are terminated with a semicolon. Multiple statements can be placed on a single program line, but that makes the code hard for others to read.

Fully qualified data fields are prefaced with the name of the record variable of which they are a part (see the preceding code line as an example where the record variable is named Phone No.). The same structure applies to fully qualified function references; the function name is prefaced with the name of the object in which they are defined.

Single quotes are used to surround string literals (see the phone number string in the preceding code line).

Double quotes are used to surround an identifier (for example, a variable or a function name) that contains any character other than numerals or uppercase and lowercase letters. For example, the Phone No. field name in the preceding code line is constructed as "Phone No." because it contains a space and a period. Other examples would be "Post Code"(contains a space), "E-Mail" (contains a dash), and "No." (contains a period).

Parentheses are used much the same as in other language-- to indicate sets of expressions to be interpreted according to their parenthetical groupings. The expressions are interpreted in sequence, first the innermost parenthetical group, then the next level, and so forth. The expression (A / (B + (C * (D + E)))) would be evaluated as follows:

  1. Summing D + E into Result1.
  2. Multiplying Result1 by C, yielding Result2.
  3. Adding Result2 to B yielding Result3.
  4. Dividing A by Result3.

Brackets [ ] are used to indicate the presence of subscripts for indexing of array variables. A text string can be treated as an array of characters, and we can use subscripts with the string name to access individual character positions within the string, but not beyond the terminating character of the string. For example, Address[1] represents the leftmost character in the Address text variable contents.

Brackets are also used for IN (In range) expressions, such as the following code snippet:

Boolean := SearchValue IN[SearchTarget]

In this line, SearchValue and SearchTarget are text variables.

Statements can be continued on multiple lines without any special punctuation; although, we can't split a variable or literal across two lines. Because the C/AL code editor limits lines to 132 characters long, this capability is often used. The following example shows two instances that are interpreted exactly in the same manner by the compiler:

ClientRec."Phone No." := '312' + '-' + '555' + '-' + '1212'; 
ClientRec."Phone No." := '312' +
'-' + '555' +
'-' + '1212';
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.241.82