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.
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)
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’
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!!