Upgrading to DataFlex 3.2: Difference between revisions

m
Marking code samples
mNo edit summary
m (Marking code samples)
Line 323: Line 323:
EXAMPLE:
EXAMPLE:


<source lang="vdf">
integer iRev
integer iRev
Open CUSTOMER
Open CUSTOMER
Line 328: Line 329:
     to iRev
     to iRev
showln "File Revision of Customer File: " iRev "."
showln "File Revision of Customer File: " iRev "."
</source>


Expression Evaluation
Expression Evaluation
Line 333: Line 335:
There have been some changes in the way logical expressions are evaluated in DataFlex revisions 3.2:
There have been some changes in the way logical expressions are evaluated in DataFlex revisions 3.2:


The standard mathematical logical operators (<,>,>=,<>,etc.) can be used in addition to the DataFlex logical operators used in DataFlex 2.3b (LT,GT,GE,etc.), provided the expression is used in parentheses.
The standard mathematical logical operators (<, >, >=, <>, etc.) can be used in addition to the DataFlex logical operators used in DataFlex 2.3b (LT, GT, GE, etc.), provided the expression is used in parentheses.
 
The Boolean logic operators AND and OR have been added.
The Boolean logic operators AND and OR have been added.
The MIN and MAX operators have been added to replace the use of < and > for this purpose, since < and > are now used as logical operators. It is important to realize how this affects evaluation of program code:
The MIN and MAX operators have been added to replace the use of < and > for this purpose, since < and > are now used as logical operators. It is important to realize how this affects evaluation of program code:
Let's use an example to illustrate this. Look at the following line of DataFlex code:
Let's use an example to illustrate this. Look at the following line of DataFlex code:


<source lang="vdf">
showln (4 > 5)
showln (4 > 5)
</source>


In DataFlex 2.3b, this line would evaluate to show "5".
In DataFlex 2.3b, this line would evaluate to show "5".
Line 345: Line 351:
The corrected line of code for DataFlex 3.2 to evaluate as it did in DataFlex 2.3 would be:
The corrected line of code for DataFlex 3.2 to evaluate as it did in DataFlex 2.3 would be:


<source lang="vdf">
showln (4 MAX 5)
showln (4 MAX 5)
</source>


The mathematical operators can now be used on strings, making their function more intuitive and compatible with other programming environments. However, this will result in some expressions evaluating differently in DataFlex 3.x than they did in 2.3.
The mathematical operators can now be used on strings, making their function more intuitive and compatible with other programming environments. However, this will result in some expressions evaluating differently in DataFlex 3.x than they did in 2.3.
Once again, let's look at an example to illustrate the differences. Consider the following lines of DataFlex code, and look at the results they will produce in DataFlex 2.3 and DataFlex 3.2:
Once again, let's look at an example to illustrate the differences. Consider the following lines of DataFlex code, and look at the results they will produce in DataFlex 2.3 and DataFlex 3.2:


<source lang="vdf">
string A
string A
string B
string B
move "3" to A
move "3" to A
move "2" to B
move "2" to B
</source>
Result:


Expression DataFlex 2.3b DataFlex 3.2
Result
showln (A + B)     5           "32"
showln (A * B)     6           "3 2"
showln (A - B)     1           "32"


Expression DataFlex 2.3b DataFlex 3.2
showln (A + B) 5 "32"
showln (A * B) 6 "3 2"
showln (A - B) 1 "32"
In DataFlex 2.3, addition of 2 string variables would result in the mathematical addition of the values in the 2 variables; in DataFlex 3.2, the 2 strings are concatenated instead.
In DataFlex 2.3, addition of 2 string variables would result in the mathematical addition of the values in the 2 variables; in DataFlex 3.2, the 2 strings are concatenated instead.