Expressions

Expressions in C/AL are made up of four elements: constants, variables, operators, and functions. We could include a fifth element, expressions, because an expression may include a subordinate expression within it. As we become more experienced in coding C/AL, we find that the capability of nesting expressions can be both a blessing and a curse, depending on the specific use and readability of the result.

We can create complex statements that will conditionally perform important control actions and operate in much the way that a person would think about the task. We can also create complex statements that are very difficult for a person to understand. These are tough to debug and sometimes almost impossible to deal with in a modification.

One of our responsibilities is to learn to tell the difference so we can write code that makes sense in operation, but is also easy to read and understand.

According to the NAV Developer and IT Pro Help, a C/AL Expression (https://msdn.microsoft.com/en-us/dynamics-nav/statements-and-expressions) is a group of characters (data values, variables, arrays, operators, and functions) that can be evaluated with the result having an associated data type. The following are two code statements that accomplish the same result in slightly different ways. They each assign a literal string to a text data field. In the first one, the right side is a literal data value. In the second, the right side of the := assignment symbol is an expression:

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.189.193.172