Sequencing of Page header and Before group
Posted in 1997
I'm getting into an awful bind with the processing order of PAGE HEADER and BEFORE GROUP OF in a 4GL report. Basically, my BEFORE GROUP OF clause sets some variables that are then used conditionally in the PAGE HEADER block. eg. PAGE HEADER LET variable = variable + 1 IF variable = 1 THEN blah ELSE yada END IF BEFORE GROUP OF a LET variable = 0 SKIP TO TOP OF PAGE Problem is that (my understanding only) the PAGE HEADER processing is deferred until the "SKIP" in the BEFORE GROUP OF *except* on the first page where the PAGE HEADER is processed before the BEFORE GROUP OF. The report certainly acts this way, in any case. So, in order to set the variable on the *first* page, I have to reproduce the BEFORE GROUP OF block in the PAGE HEADER like this; PAGE HEADER IF pageno = 1 THEN LET variable = 0 END IF LET variable = variable + 1 IF variable = 1 THEN blah ELSE yada END IF BEFORE GROUP OF a LET variable = 0 SKIP TO TOP OF PAGE However, the variables I am setting are tracking the logical page numbers within a GROUP, and the BEFORE GROUP *does* get executed on the first page which mucks up the assignments. To get around this I need a conditional in the BEFORE GROUP OF like so; PAGE HEADER IF pageno = 1 THEN LET variable = 0 END IF LET variable = variable + 1 IF variable = 1 THEN blah ELSE yada END IF BEFORE GROUP OF a IF pageno = 1 THEN LET variable = 1 ELSE LET variable = 0 END IF SKIP TO TOP OF PAGE Getting ugly, eh? But there's more. Because the pageno doesn't change until the "SKIP", the second page of the report (if it is a new group) still has pageno = 1 and so gets variable = 2 after the PAGE HEADER executes. And I can't put the "SKIP" at the top of the BEFORE GROUP because then the PAGE HEADER executes immediately before the variables are set. I can write spagetti to circumvent all this, but I'm sure there's something I'm missing that could turn it into a nice grilled trout with buttered potatoes (maybe some sour cream). Sorry if I'm not explaining myself well, it's late and my eyes are getting screen burn. Sorry if it's plainly obvious what to do, it's late and my eyes are getting screen burn. I tried mucking about with AFTER GROUP which only made things more convoluted. Thanks in advance [Anyone from Sarf Efrica - Shane Warne's warming up against the Kiwis, rumour has it that Mr Cronje's boys are already starting to fake injuries to try and get out of the Tests :) ] -- Bryan Tonnet batonnet@phase4.com.au