Dynamic formation of logical condition

Hi,

I was wondering if we can evaluate any dynamic condition in Natural. eg please have a look at this program
DEFINE DATA
LOCAL
1 #A (L)
1 #B (L)
1 #ST (A10)
END-DEFINE
#ST := ‘#A OR #B
IF #ST /* <----- THIS IS WRONG OBVIOUSLY.
WRITE ‘=’ #ST
END-IF
END

I tried using a copycode for this. But that too did not work out because of type checking.

Can this be done in natural?

No, that won’t work, copycodes are evaluated during compile time, their main purpose is reuse of code fragments.

The only way to get real “dynamic” stuff is to generate the code at runtime.

Exactly … and I am not able to come up with any sort of workaround for this.
Very frustrating … It shouldn’t be this difficult.

Education, education, education.

You are obviously new to Natural, and have never had any education in Natural.

Wolfgang told you what had to be done, but you have no idea how to do it.

Consider the following program excerpt:

:::
IF #FIELD = &CONDITION
::

At compile time, Natural looks for a global variable (old style), or a variable in a GDA (new style) that is called +CONDITION. The compiler then takes the contents of +CONDITION and replaces &CONDITION in the program.

So, you need a “driver” program, such as shown below (old style)

INPUT ‘enter logical condition here==>’ +CONDITION (A50)

  • validate entered value here

IF condition entered is okay
RUN ‘REPORT’ /* where REPORT is the program with the &CONDITION above.

Suppose the user enters #TEST-VALUE for +CONDITION

When you RUN ‘REPORT’ the first thing Natural does is compile the program REPORT. When Natural “sees” &CONDITION, it replaces it with #TEST-VALUE. You now have a valid Natural statement, namely
IF #FIELD = #TEST-VALUE

Suppose the user enters ‘ABC’ for +CONDITION
You now have the valid Natural statement
IF #FIELD = ‘ABC’

Your employer should supply Natural education !!

Thanks for your reply. You totally got me there.
I was looking at USR4208N for this. But this works perfectly and solves the purpose.
I think I need to find a documentation on natural compile time validation.
Thanks again!!