Focal Point
[SOLVED] html Composer (text Box variable)

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

March 08, 2010, 03:04 PM
adFocus
[SOLVED] html Composer (text Box variable)
Hi all,
I have a text box (Html composer) that takes a number and passes it to a procedure. When I type a number it works fine. However, when there is no number (blank field) it fails to generate the report. Here is the code I used to check for 0 or null value in the .fex

-IF ('&XFIELD' EQ '' OR 0 OR NULL) THEN GOTO XFIELD;
WHERE (FIELDA EQ '&XFIELD');
-XFIELD

Please note the Field in the DB I am verifying against is Number(7)

Please advise.

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


WebFOCUS 7.6.8
Windows
Excel, HTML
March 08, 2010, 03:13 PM
Francis Mariani
Do you get an error message?

I would code the IF statement slightly differently:

-IF &XFIELD.EXISTS EQ 0 GOTO XFIELD;
-IF &XFIELD EQ '' OR &XFIELD EQ 0 GOTO XFIELD;
WHERE (FIELDA EQ '&XFIELD');
-XFIELD



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
March 08, 2010, 03:24 PM
Dan Satchell
Set a default value of 0 for the variable so it will have that value if the user does not enter one.

-DEFAULT &XFIELD = 0
-IF (&XFIELD EQ 0) GOTO XFIELD ;
WHERE (FIELDA EQ &XFIELD);
-XFIELD



WebFOCUS 7.7.05
March 08, 2010, 04:15 PM
Doug
HINT: Always use a DEFAULT for variable which may / may not be present. Actually, why not always use a DEFAULT for a variable? It makes easy testing and HTML Composing... I do something like
-DEFAULT &MyVar = '*' ;
-SET &MyVar = IF &MyVar EQ '*' THEN This ELSE That ;
... Continue with code
However, if your variable is coming in for the composer (Launch Page) then why not pass in a FOC_NONE? Then there's no need for branching...




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
March 09, 2010, 12:32 AM
Ram Prasad E
-DEFAULT &XFIELD=FOC_NONE;
-SET &XFIELD=IF &XFIELD EQ 0 THEN FOC_NONE ELSE &XFIELD;

TABLE FILE ZZZ
PRINT
...
WHERE FIELDA EQ &XFIELD;
END


Make sure to place the WHERE statement that checks for &XFIELD in a separate line,without mixing with other conditions. When FOC_NONE is passed, WebFOCUS Server's 'Describe' layer will remove the entire line.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
March 09, 2010, 11:06 AM
adFocus
quote:
-DEFAULT &XFIELD=FOC_NONE;
-SET &XFIELD=IF &XFIELD EQ 0 THEN FOC_NONE ELSE &XFIELD;


Thank you all, This works great.


WebFOCUS 7.6.8
Windows
Excel, HTML