IF & ELSE

navuser1navuser1 Member Posts: 1,329
edited 2014-10-22 in NAV Three Tier
Dear Sir,

In a certain scenario I have to check a Boolean value of a table field repeatedly & then do the work. Suppose the same found occasionally(Boolean = TRUE) in a Record Set, so my code should follow the Method-1 or Method-2.

Method-1
IF Boolean = TRUE THEN
 DO
ELSE
 DO NOTHING/SKIP/EXIT ;
Method-2
IF Boolean = FALSE THEN
 NOTHING/SKIP/EXIT
ELSE
 DO  ;

Is there any difference between these two ??
Kindly reply.
Now or Never

Comments

  • TonyDuarteTonyDuarte Member Posts: 92
    The both methods seem to be the same the only thing is that the boolean check is changed, in both cases the "True" value will result in executing the code and the "False" to do Nothing/Skip/Next...
  • navuser1navuser1 Member Posts: 1,329
    TonyDuarte wrote:
    The both methods seem to be the same the only thing is that the boolean check is changed, in both cases the "True" value will result in executing the code and the "False" to do Nothing/Skip/Next...

    Exactly!

    What Should I check the (Boolean = TRUE) or (Boolean = FALSE) first when I know that the record set contains the (Boolean = TRUE) rarely.

    Does any sequence matter ?
    Now or Never
  • MarijnMarijn Member Posts: 69
    Sequence does matter for performace. The condition which happens most frequently should be dealt with first. Although it will be very hard to measure, if it can be done. I consider it a good habit. Also, use shorthand, like IF MyBoolean or IF NOT MyBoolean instead of using the = sign. Looks more professional.
Sign In or Register to comment.