Focal Point
dialogue manager and goto

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

May 10, 2006, 10:51 AM
Pam Kratt
dialogue manager and goto
I'm doing the following looping (not all the code is here). The looping is working except when I try to create a graph and there is no data to graph. I display -TYPE &NOGRAPH;
-TYPE &CLOSEPDF;
-TYPE &RECORDS;
and the values are (nograph) Y (closepdf) Y and (records=) 0. So, when I do my check of -IF &RECORDS EQ 0 GOTO EMPTYRPT; it should go to emptyrpt but it's not going there. It's falling down into the code immediately below the if. If I only do 1 account that has no data it goes correctly to the emptyrpt. What am I doing wrong? Thanks.

-SET &COUNT = 1;
-REPEAT PDFLOOP WHILE &COUNT LE &NOOFACCTS;
SET PAGE-NUM=NOPAGE

-* CHECK THAT PERCENTAGE IS GE 1 SO THAT ONLY ITEMS ON GRAPH APPEAR IN LEGEND
SET LOOKGRAPH=PIE
SET 3D=OFF
GRAPH FILE HOLD220
SUM PCT_MKT_VL AS ""
BY SEC_GRP_NM
WHERE MKT_VL IS-NOT MISSING AND MKT_VL GT 0 AND PCT_MKT_VL GE 1
WHERE SORTORDER EQ &COUNT
ON GRAPH SET VAXIS 4
ON GRAPH SET HAXIS 6
ON GRAPH SET GRAPHSTYLE *
setFillColor(getSeries(0),new Color(0,0,255)); blue
ENDSTYLE
ON GRAPH SAVE AS ALLOC&COUNT FORMAT SVG
END

-* CHECK TO SEE IF A GRAPH WAS CREATED
-RUN
-SET &NOGRAPH=IF &RECORDS EQ 0 THEN ‘Y’ ELSE ‘N’;
-SET &CLOSEPDF=IF &RECORDS EQ 0 AND &COUNT EQ &NOOFACCTS THEN 'Y' ELSE 'N';
-SET &TITLE2 = IF &RECORDS EQ 0 THEN 'No Data Available For This Account' ELSE
- '-TYPE &NOGRAPH;
-TYPE &CLOSEPDF;
-TYPE &RECORDS;

-IF &RECORDS EQ 0 GOTO EMPTYRPT;
-* THE BELOW IS MODIFIED CODE TO GIVE THE IDEA OF WHAT I'M DOING.
TABLE FILE HOLD200
PRINT ACCOUNTID
-* CHECK IF IT'S THE LAST RECORD AND IF THERE IS NO GRAPH AND CLOSE
-* PDF FILE IF IT IS
-IF &COUNT GE &NOOFACCTS THEN GOTO CLOSEPDF;
ON TABLE PCHOLD FORMAT PDF
-GOTO PDFEND2
-CLOSEPDF
ON TABLE PCHOLD FORMAT PDF CLOSE
-PDFEND2
END

-EMPTYRPT
TABLE FILE HOLD200
PRINT ACCOUNTID
HEADING
"No Data to display"
-* CHECK IF IT'S THE LAST RECORD AND IF THERE IS NO GRAPH AND CLOSE
-* PDF FILE IF IT IS
-IF &COUNT GE &NOOFACCTS THEN GOTO CLOSEPDF2;
ON TABLE PCHOLD FORMAT PDF
-GOTO PDFEND
-CLOSEPDF2
ON TABLE PCHOLD FORMAT PDF CLOSE
-PDFEND
END


webfocus 8.105M; os: windows; pdf, html, exl2k, csv
May 10, 2006, 11:35 AM
ptp
-TYPE lines shouldn't need a semi-colon to terminate them. I doubt it's solely reponsible, but you never know...

Paul.
May 10, 2006, 11:42 AM
Pam Kratt
I actually put the semi colons in because the code wasn't working and I thought maybe it wasn't reading the if statement


webfocus 8.105M; os: windows; pdf, html, exl2k, csv
May 10, 2006, 12:27 PM
<Special-K>
Not sure what's going on but instead of checking

-IF &RECORDS EQ 0 GOTO EMPTYRPT;

try

-IF &NOGRAPH EQ 'Y' GOTO EMPTYRPT;

as you know this has been set correctly.
May 10, 2006, 12:29 PM
<RickW>
I'm assuming your already using -SET &ECHO=ALL; (or ON) to validate how it's working.

You might need to check &LINES instead of &RECORDS.

Is your value for &NOOFACCTS set correctly?

Instead of REPEAT you may need to use the old school method - something like...

-SET &CNTR = 0;
-STARTLOOP
-SET &CNTR = &CNTR +1;
-IF &CNTR GT &NOOFACCTS GOTO ENDLOOP;
TABLE FILE HOLD
PRINT BLAH BLAH BLAH
END
-RUN
-GOTO STARTLOOP
-ENDLOOP

Hope that helps.
May 10, 2006, 01:46 PM
j.gross
Several observations:

quote:
-REPEAT PDFLOOP WHILE &COUNT LE &NOOFACCTS;


1. I don't see the -PDFLOOP label in your posted code.


quote:

-* CHECK TO SEE IF A GRAPH WAS CREATED
-RUN
-SET &NOGRAPH=IF &RECORDS EQ 0 THEN ‘Y’ ELSE ‘N’;
...
-SET &TITLE2 = IF &RECORDS EQ 0 THEN 'No Data Available For This Account' ELSE
- '-TYPE &NOGRAPH;
...
-IF &RECORDS EQ 0 GOTO EMPTYRPT;


2. If there is any code whatsovever between the -RUN and the -IF &RECORDS (or &LINES) test, best practice is to set your own &var (such as your &NOGRAPH) and test that.

3. "-SET &TITLE2" has unbalanced quotes. Perhaps there's something interesting between the lines.

4. &RECORDS can give false positives if you have IF TOTAL tests; use &LINES instead.
May 10, 2006, 02:43 PM
Pam Kratt
I changed to use the following code after the graph:
-RUN
-SET &NOGRAPH=IF &LINES EQ 0 THEN ‘Y’ ELSE ‘N’;
-SET &CLOSEPDF=IF &LINES EQ 0 AND &COUNT EQ &NOOFACCTS THEN 'Y' ELSE 'N';

-TYPE &NOGRAPH
-TYPE &CLOSEPDF
-TYPE &RECORDS
-TYPE &LINES

I'm noticing the following are the results of my -type ... do you know why I would get ? around the Y? I think that may be problem. The ?y? is the result for &NOGRAPH.

?Y?
N
0
0


webfocus 8.105M; os: windows; pdf, html, exl2k, csv
May 10, 2006, 02:47 PM
susannah
agreed.
use &LINES and save it IMMEDIATELY after your extract.
ON GRAPH SAVE AS ALLOC&COUNT FORMAT SVG
END
-RUN
-SET &HOWMANY = &LINES;

..now go ahead and type and check whatever you like. these &LINES vars get reset to 0 very easily, so make sure you grab it immediately.
as for the ?, in the code you copied, the marks around the Y and N in the first SET look different from the marks around the Y and N in the second SET; If your surround your code snippet with the code tags, we can see it better.

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 10, 2006, 03:00 PM
Pam Kratt
the problem ended up being the quotes. The code must have been copied and they were not normal quotes on the set &nograph. Once I fixed the quotes the if statements appear to be working. More testing is needed but I think I have it. Thanks for the many helpful hints ... I didn't know that about &lines vs &records so that was helpful too.


webfocus 8.105M; os: windows; pdf, html, exl2k, csv