Evaluation of boolean expressions in controll statements

mabl4367
Member Posts: 143
I have some questions about the evaluation of boolean expressions in controll statements. Lets start with the folowing:
IF (A=B) AND (C=D) THEN;
Are both expressions always evaluated, even if A=B is FALSE?
What if one expression contains a function call:
IF (A=B) AND myRecord.GET(primKeyVal1,primKeyVal2,...) THEN;
Can I always count on GET to be executed or is it only executed if A=B is TRUE?
IF (A=B) AND (C=D) THEN;
Are both expressions always evaluated, even if A=B is FALSE?
What if one expression contains a function call:
IF (A=B) AND myRecord.GET(primKeyVal1,primKeyVal2,...) THEN;
Can I always count on GET to be executed or is it only executed if A=B is TRUE?
0
Comments
-
mabl4367 wrote:I have some questions about the evaluation of boolean expressions in controll statements. Lets start with the folowing:
IF (A=B) AND (C=D) THEN;
Are both expressions always evaluated, even if A=B is FALSE?
What if one expression contains a function call:
IF (A=B) AND myRecord.GET(primKeyVal1,primKeyVal2,...) THEN;
Can I always count on GET to be executed or is it only executed if A=B is TRUE?
Hi
Navision resolve every statement of a "IF" instruction.
On your example, the GET method will be executed if A=B and A<>B.
You can change it like
IF (A=B) THEN
IF myRecord.GET(primKeyVal1,primKeyVal2,...) THEN;
Bye
MatteoReno Sistemi Navision Developer0 -
Thanks a bunch!0
-
So for all those former OO programmers out there (me included), short circuiting is not supported...at least I think that's what it was called...wow, it's been a long time.0
-
Here is a related question:
What will this code do?
CLEAR(myRecord);
myRecord.INIT();
myRecord.myFiled:='Hello!'
myRecord.INSERT();
primaryKey:=myRecord.primaryKey;
CLEAR(myRecord);
IF myRecord.GET(primaryKey) AND (myRecord.myField='Hello!') THEN
MESSAGE('myRecord.myFiled= %1',myRecord.myField)
ELSE
MESSAGE('myRecord: %1 could not be found or the myRecord.myField!=Hello!',primaryKey);
The question is: Will the evaluation of myRecord.GET(primaryKey) be preformed first and will myRecord contain the newly inserted record when the evaluation of myRecord.myField='Hello!' is preformed?0 -
mabl4367 wrote:I have some questions about the evaluation of boolean expressions in controll statements. Lets start with the folowing:
IF (A=B) AND (C=D) THEN;
Are both expressions always evaluated, even if A=B is FALSE?
What if one expression contains a function call:
IF (A=B) AND myRecord.GET(primKeyVal1,primKeyVal2,...) THEN;
Can I always count on GET to be executed or is it only executed if A=B is TRUE?
No you can not. There is no (official) documentation on this and it is planned to change in the future. So even though it will work in the current version it probably wont in the future.
There was a very good session at Directions where this was explained. So don't rely on unsupported features.David Singleton0 -
I totally agree with above statement.
But maybe the same could be said about this.
viewtopic.php?f=23&t=39842&p=195384#p1953840 -
generic wrote:I totally agree with above statement.
But maybe the same could be said about this.
viewtopic.php?f=23&t=39842&p=195384#p195384
How so?David Singleton0 -
there is no documentation for it.0
-
generic wrote:there is no documentation for it.
Wrong...
This feature has been in Navision since I started using Navision in the DOS version.
Go to the property and hit F1 you will see it is fully documented and always has been. \:D/David Singleton0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions