Upgrading to DataFlex 3.2: Difference between revisions

m
Line 344: Line 344:
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">
<source lang="vdf">
Line 354: Line 354:
</source>
</source>


In DataFlex 2.3b, this line would evaluate to show "5".
:In DataFlex 2.3b, this line would evaluate to show "5".


In DataFlex 3.2, this line will evaluate to show "0" (meaning "False", since 4 is not greater than 5).
:In DataFlex 3.2, this line will evaluate to show "0" (meaning "False", since 4 is not greater than 5).


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">
<source lang="vdf">
Line 364: Line 364:
</source>
</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">
<source lang="vdf">
Line 375: Line 375:
</source>
</source>


Result:
 
Expression     DataFlex 2.3b DataFlex 3.2
:{| class="wikitable"
showln (A + B)     5           "32"
!colspan="1"|
showln (A * B)     6           "3 2"
!colspan="2"|'''Results'''
showln (A - B)     1           "32"
|-
|'''Expression'''
|'''DataFlex 2.3b'''
|'''DataFlex 3.2'''
|-
|showln (A + B)
|style="text-align:center;" | 5
|style="text-align:center;" | "32"
|-
|showln (A * B)
|style="text-align:center;" | 6
|style="text-align:center;" | "3 2"
|-
|showln (A - B)
|style="text-align:center;" | 1  
|style="text-align:center;" | "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.