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?
0
Comments
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
Matteo
My Blog - nav.education
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?
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.
But maybe the same could be said about this.
viewtopic.php?f=23&t=39842&p=195384#p195384
How so?
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/