Reading control variable content in IF statement

I have a control variable #CV wich is initially set to (AD=N). During the course of the program it may be set to (AD=P), to become visible.

Later on, I want to check if it is set to N or P so I can define it as (AD=N) to become inputtable or so I can display an error message.

How do I check “IF #CV = P” or “IF #CV = (AD=P)”?

I don’t believe this is available even with Natural 8. Natural allows you to determine whether the field contents have been modified, but that’s all.

You already have logic to set the CV to (AD=P) or (AD=N), etc. You’ll have to use the same logic to determine the current settings of the CV.

1 Like

First, I am somewhat confused by your post.

AD=N means non displayable. The converse of this would be AD=D which is displayable, normal intensity.

AD=P means protected. You would apply this to variables that are AD=A or AD=M to temporarily make them protected.

So, perhaps you should re-examine your settings.

As far as using an IF, you can redefine a control, variable as binary and use it as shown below:

0010 DEFINE DATA LOCAL
0020 1 #CVP (C) INIT <(AD=P)>
0030 1 REDEFINE #CVP
0040 2 #CVPB (B2)
0050 1 #CVN (C) INIT <(AD=N)>
0060 1 REDEFINE #CVN
0070 2 #CVNB (B2)
0080 1 #C (C)
0090 1 REDEFINE #C
0100 2 #CB (B2)
0110 END-DEFINE
0120 *
0130 MOVE (AD=P) TO #C
0140 IF #CB = #CVPB
0150 WRITE ‘YES, WE HAVE A P’
0160 ELSE
0170 WRITE ‘NO P SPECIFIED’
0180 END-IF
0190 *
0200 MOVE (AD=N) TO #C
0210 IF #CB = #CVNB
0220 WRITE ‘YES, WE HAVE AN N’
0230 ELSE
0240 WRITE ‘NO N SPECIFIED’
0250 END-IF
0260 END

This basically assumes the only values assigned would be AD=P or AD=N.

As mentioned above, I would re-examine what you are trying to do. It seems you are making something very complicated from something that should be very simple.

1 Like

Steve, I’m designing a search screen in wich, depending of the search criteria, the fields will go through 3 availability states: “N”, “P” and finally “D”.

In this case, the only state that matters to me is if it’s set to “P”, so the user may choose from a menu, that option. If it’s is state is “N” an error will be displayed.

I was trying to code it without one more variable, but as Ralph’s answer states it’s not possible. I will use the implementation you suggested. Thank you.