Abe Froman
Member
I'm getting spiritually drained trying to get this to work and researching why it doesn't, so I thought I'd just ask if anyone knows.
Basically, I want to setup a testing flag to help make sure test files don't get FTP'd off to a production server and cause trouble.
Later in my code, I use &IF DEFINED to set the FTP parameters to the correct server. Works as it should.
However, I want to save some trouble and have the flag be one-stop shopping when it comes to turning on/off the testing situation. No more forgetting to comment out something critical in the middle of the code, but this should also replaces the standard "comment out the input vars and uncomment the testing vars" drudgery with something like this:
When running, it seems to be acting like the input parameter vars are both defined and not defined. It compiles fine (which wouldn't happen if variables are defined twice), but when running it errors out saying that the wrong number of parameters were passed to the program.
What do I not understand? I don't use preprocessors all the time, but what is the point of &IF-&ELSE if it doesn't 'take' all the time?
Basically, I want to setup a testing flag to help make sure test files don't get FTP'd off to a production server and cause trouble.
Later in my code, I use &IF DEFINED to set the FTP parameters to the correct server. Works as it should.
However, I want to save some trouble and have the flag be one-stop shopping when it comes to turning on/off the testing situation. No more forgetting to comment out something critical in the middle of the code, but this should also replaces the standard "comment out the input vars and uncomment the testing vars" drudgery with something like this:
Code:
/* Uncomment to use Testing variables and parameters */
DEF VAR NowTesting AS LOG NO-UNDO.
&IF DEFINED(NowTesting) <> 0 &THEN
DEF VAR v-plant AS CHAR FORMAT "x(4)" INIT "1111" NO-UNDO.
DEF VAR v-item-nbr AS CHAR FORMAT "x(15)" INIT "12345678" NO-UNDO.
DEF VAR v-qty AS INT INIT 1 NO-UNDO.
DEF VAR v-job-type AS CHAR FORMAT "x(4)" INIT "XXX" NO-UNDO.
DEF VAR v-job-nbr AS CHAR FORMAT "x(25)" INIT "123456789" NO-UNDO.
&ELSE
DEF INPUT PARAMETER v-plant AS CHAR FORMAT "x(4)" NO-UNDO.
DEF INPUT PARAMETER v-item-nbr AS CHAR FORMAT "x(15)" NO-UNDO.
DEF INPUT PARAMETER v-qty AS INT NO-UNDO.
DEF INPUT PARAMETER v-job-type AS CHAR FORMAT "x(4)" NO-UNDO.
DEF INPUT PARAMETER v-job-nbr AS CHAR FORMAT "x(25)" NO-UNDO.
&ENDIF
When running, it seems to be acting like the input parameter vars are both defined and not defined. It compiles fine (which wouldn't happen if variables are defined twice), but when running it errors out saying that the wrong number of parameters were passed to the program.
What do I not understand? I don't use preprocessors all the time, but what is the point of &IF-&ELSE if it doesn't 'take' all the time?