Focal Point
Problems with Dialog Manager if statment

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

May 12, 2006, 08:36 AM
OlafMeyer
Problems with Dialog Manager if statment
Hello,

I found a very strange behavior in the Dialog Manager. I’m trying to test whether the content of a variable is empty or not. The variable is supplied from a launch page. For this I’m using the following statement:

-IF &VAR1.EXISTS THEN GOTO STEP01 ELSE GOTO DONE
-STEP01
-IF ‘&VAR1.EVAL’ NE ‘’ THEN GOTO STEP02 ELSE GOTO DONE
-STEP02
WHERE TEST EQ VAR1;
-DONE
So if the variable &VAR1 contains ‘000000’ as the content, I would assume that the result would be:
-IF 1 THEN GOTO STEP01 ELSE GOTO DONE
-STEP01
-IF ‘00000’ NE ’ THEN GOTO STEP02 ELSE GOTO DONE
-STEP02
WHERE TEST EQ VAR1;
-DONE

Instead the result is:
-IF 1 THEN GOTO STEP01 ELSE GOTO DONE
-STEP01
-IF ‘00000’ NE ‘ THEN GOTO STEP01 ELSE GOTO DONE
-DONE

How can this happen? Does anybody have a solution for my problem?

Thank you
May 12, 2006, 09:00 AM
Tony A
Olaf,

You need to teminate your DM IF statement with a semi-colon and I would remove the EVAL -

-IF &VAR1.EXISTS THEN GOTO STEP01 ELSE GOTO DONE;
-STEP01
-IF '&VAR1' NE '' THEN GOTO STEP02 ELSE GOTO DONE;
-STEP02
WHERE TEST EQ VAR1;
-DONE


However, I would prefer to use -

-IF NOT(&VAR1.EXISTS) THEN GOTO DONE;
-STEP01
-IF '&VAR1' EQ '' THEN GOTO DONE;
-STEP02
WHERE TEST EQ VAR1;
-DONE


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
May 12, 2006, 09:20 AM
OlafMeyer
Hello Tony,

thanks for your comment. The actual if statements are terminated with a semincolon. I tried your code and the result was the same. It looks likes this:
-IF NOT(1) THEN GOTO DONE;
-STEP01
-IF '000000' EQ '' THEN GOTO DONE;
-DONE

How comes that for the comparation both values are equal?

Olaf

quote:
Originally posted by Tony A:
Olaf,

You need to teminate your DM IF statement with a semi-colon and I would remove the EVAL -

-IF &VAR1.EXISTS THEN GOTO STEP01 ELSE GOTO DONE;
-STEP01
-IF '&VAR1' NE '' THEN GOTO STEP02 ELSE GOTO DONE;
-STEP02
WHERE TEST EQ VAR1;
-DONE


However, I would prefer to use -

-IF NOT(&VAR1.EXISTS) THEN GOTO DONE;
-STEP01
-IF '&VAR1' EQ '' THEN GOTO DONE;
-STEP02
WHERE TEST EQ VAR1;
-DONE


T

May 12, 2006, 10:03 AM
Tony A
Hi Olaf,

I have just run the second version and recieved the following output -
-DEFAULT &VAR1 = 000000
-IF NOT(1) THEN GOTO DONE;
-STEP01
-IF '000000' EQ '' THEN GOTO DONE;
-STEP02
-*WHERE TEST EQ VAR1;
-DONE


I commented out the WHERE statement because I was only using the DM function.

What platform and release are you using? This was tested with WF 5.3.2 on Windows 2003 servers using Dev Studio on XP.

I get exactly the same result on rel 7.1.3.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
May 12, 2006, 10:52 AM
JohnK
Olaf

Try this code:

-DEFAULT &VAR1=;
-RUN
-STEP01
-IF '&VAR1.EVAL' EQ ' ' THEN GOTO DONE;
-STEP02
WHERE TEST EQ VAR1;
-DONE
-EXIT

John K
May 12, 2006, 11:09 AM
OlafMeyer
Hello Tony,

we are using Solaris 8 and WebFocus 5.3.2. Might the OS cause the problem?

Thank you for your help.

Olaf
May 12, 2006, 12:43 PM
susannah

-SET &ECHO = ALL ;
TABLE FILE CAR
PRINT CAR COUNTRY SEATS
-IF NOT(&VAR1.EXISTS) THEN GOTO DONE;
-STEP01
-IF  &VAR1  EQ ' ' THEN GOTO DONE;
-STEP02
WHERE SEATS GT &VAR1 
-DONE
END
-RUN
 

in your screening condition, you need to make VAR1 the ampver var &VAR1
and..
if it is a literal, not a value, you'll need to enclose it in quotes, otherwise IF COUNTRY EQ FRANCE will bomb, it'll look for a field named FRANCE.
and ... sometimes i have found that EQ '' must be replaced with EQ ' ' (put a space in)
the .LENGTH operator on an &var shows a minimum of 1, and never 0. go figure. something about just addressing it makes it exist...dunno...i think someone else explained it to me once.

This message has been edited. Last edited by: susannah,




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 12, 2006, 02:25 PM
TexasStingray
OlafMeyer

I'm assuming you want '000000' to not be treated as '' here is a way. Also CHECK out the usage of setting a variable to a value of FOC_NONE

-DEFAULT &VAR1 = '';
-IF 'X&VAR1.EVAL' NE 'X' THEN GOTO :SKIPSET;
-SET &VAR1 = 'FOC_NONE';
-:SKIPSET

TABLE FILE CAR
PRINT CAR COUNTRY SEATS
WHERE COUNTRY EQ '&VAR1';
END


In the above code if I default the variable var1 to blank I get all rows. If I default it to 'ENGLAND' I only get ENGLAND. If I default it to '000000' I get no data.

FOC_NONE tell the WebFOCUS parser the throw away the statement.

Hope this Helps




Scott

quote:
Originally posted by susannah:
if it is a literal, not a value, you'll need to enclose it in quotes, otherwise IF COUNTRY EQ FRANCE will bomb, it'll look for a field named FRANCE.


The right-hand side of the condition in IF is always taken to be a literal value.

But the quotes are harmless, and will save you if the supplied value has an imbedded space.
oh yeah, thats probably for a WHERE statement.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Thank you for comments.

It seams that there is a problem in Solaris with the comparison of zeros with an empty string or a string with a blank. This might only happen with Solaris. I hope in newer version this bug will be fixed.
Do not forget the ASIS function for discriminating between 0 and blank in DM.