hexagon logo

PCDMIS True/False Variable Issue

All,

From what I understand, a variable in a PCDMIS conditional statement PCDMIS evaluates True / False conditionals by checking ONLY if the numeric value is ZERO (aka False). Anything else evaluates to True.

In Example 1, the Operator Comment does NOT execute:

ASSIGN/V1=0
IF/V1
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
Hello!
END_IF/ 

In Example 2, the Operator comment executes if V1 is anything OTHER THAN ZERO.

ASSIGN/V1=3
    IF/V1
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    Hello!
END_IF/

Has anyone found this NOT to work as described above?

Are there issues if the variable holds a string value?

Thanks,

Mike (in snowy Buffalo)

  • I believe (I don't know for sure RE PC-DMIS) it's standard programming practice that if a variable holds any value other than 0 for numeric or NULL for strings, it should return 1 (True). However, I was also taught that there should always be an explicit conditional for IF statements. Ex. IF A=3 or IF B="SOMETHING" THEN

    Dis (In less-snowy Rochester)

  • As far as I know, you are correct.  The help file says: "The items between the IF and the END IF commands will only execute if the expression for the IF command evaluates to true (nonzero)". 

    I haven't tried that with string variables.  It would seem to me that any string that is not empty would then evaluate as true.  It could be a quick way to check if a user entered data on input comment.  However, I just tried this and found that assigning a string with "0000" actually returns a FALSE.  So, there is an edge case where that wouldn't work.  

  • You stated IF/V1, but you never specified what V1 needs to equal. It should say, "IF/V1=="3" " or something like that. Or IF/V1<"3" to equate to anything under 3. 

    Just putting IF/V1 will result in PC-DMIS completely skipping it.

  • Not true.  It is common in many programming languages to have true/false variables (Boolean variables).  They exist only to store a one or a zero - true or false.  So, you can just use an IF command followed by that variable in conditional statements.  It works in PC-DMIS, but I tend to be squeamish about doing it because you don't declare variable types (I think it uses all variables as variants), so I worry that a zero won't always be considered a true zero.