Focal Point
Strange Dialog Manager behaviour

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9211097331

July 21, 2004, 09:54 PM
<Pietro De Santis>
Strange Dialog Manager behaviour
This is weird. I have a snippet of DM code:
-SET &ECHO=ALL;

-SET &VAL1 = '';

-SET &TEST1 =
- IF (&VAL1 EQ '.') THEN 'XXX' ELSE 'YYY';

-SET &TEST2 =
- IF ('&VAL1' EQ '.') THEN 'XXX' ELSE 'YYY';

-SET &TEST3 =
- IF ('&VAL1.EVAL' EQ '.') THEN 'XXX' ELSE 'YYY';

-TYPE TEST1: &TEST1
-TYPE TEST2: &TEST2
-TYPE TEST3: &TEST3
that does not work correctly.

When I set the value of &VAL1 to '.', I would expect the result to be XXX, but it is not for TEST2.

When I set the value of &VAL1 to '', I would expect the result to be YYY, but it is not for TEST1 and TEST3.

When I set the value of &VAL1 to 'a', it works correctly - I get YYY for all three TEST values.

I had to do this to make it work.

-SET &ECHO=ALL;

-SET &VAL0 = '.';
-SET &VAL1 = 'X' || &VAL0 || 'X';

-SET &TEST1 =
- IF (&VAL1 EQ 'X.X') THEN 'XXX' ELSE 'YYY';

-TYPE TEST1: &TEST1
What's happening here?

This message has been edited. Last edited by: <Mabel>,
July 22, 2004, 02:49 PM
reFOCUSing
Lets see if I can explain this correctly.

To my understanding the reason you are getting incorrect results is because of when the amper variable is being evaluated. By using &VAL1 and '&VAL1.EVAL' they will be replaced with there value before the code runs. '&VAL1' will be replaced with its value after the code runs, this is why it looks right. Since '&VAL1' and '&VAL1.EVAL' are strings not variables by using .EVAL in the string it will cause the variable to replaced with its value before the if statement is processed.

-SET &ECHO=ALL;
-SET &VAL1 = '.';
-SET &TEST1 = IF ('Hi &VAL1' EQ 'Hi .') THEN 'XXX' ELSE 'YYY';
-SET &TEST2 = IF ('Hi &VAL1.EVAL' EQ 'Hi .') THEN 'XXX' ELSE 'YYY';
-TYPE TEST1: &TEST1
-TYPE TEST2: &TEST2

Also if you have a variable that could be '' you may want to use the function ASIS() since '' and 0 will evaluate to the same thing.

-SET &ECHO=ALL;
-SET &VAL1 = '';
-SET &VAL2 = 0;
-SET &TEST1 = IF (ASIS('&VAL1.EVAL') NE 0) THEN 'XXX' ELSE 'YYY';
-SET &TEST2 = IF (ASIS('&VAL2.EVAL') NE 0) THEN 'XXX' ELSE 'YYY';
-SET &TEST3 = IF ('&VAL1.EVAL' NE 0) THEN 'XXX' ELSE 'YYY';
-SET &TEST4 = IF ('&VAL2.EVAL' NE 0) THEN 'XXX' ELSE 'YYY';
-TYPE TEST1: &TEST1
-TYPE TEST2: &TEST2
-TYPE TEST3: &TEST3
-TYPE TEST4: &TEST4
July 22, 2004, 02:54 PM
<Pietro De Santis>
Curtis, thanks for your explanation. I was aware of the difference between '&AVR.EVAL, '&VAR' and '&VAR', but this does not explain why, when the amper value being tested is a . (dot), the DM code does not work.

Thanks,

Pietro.
July 23, 2004, 10:22 AM
susannah
hmmm what an intersting prob.
The dot operator is a comment signal to scripting languages, so i'm guessing that DM somehow is tripping over that.
The empty is more puzzling:
given &VAL1='';
then &VAL1.EXIST equals 1
and &VAL1.LENGTH also equals 1
both of which are counter-intuitive results ,to me. I'm expecting 0 at least for the second test. Meaning &VAL1=''; is the same as &VAL1=' ';, hmmm.
How about seeing if the hex translation is a hex40, a real blank.
Your work around certainly seems totally reasonable.
July 23, 2004, 06:01 PM
suzy_smith
What is your NODATA setting? I seem to remember that we had some problems with a DM situation with NODATA = . (dot, that is).