Re: RETURN within REPORT -- Danger Will Robinson!
Posted in 1993
In <29ejqtINNkm1@emory.mathcs.emory.edu> walt@mathcs.emory.edu (Walt Hultgren {rmy}) writes: >The recent discussion about forcing at least one page from a report that >receives no data caused me to make another attempt at finding a general >solution to the problem. Similar here (printing custom headers inside a single report actually made up of multiple types of similar reports), same solution implemented -- then I realized I'd been zapped... >I have recently been thinking about using a method, demonstrated in the >test program below, that depends on using a RETURN statement within a >REPORT module, as in Line 70 of the program. >I couldn't find any specific mention of *not* using RETURN inside REPORTs >in the manuals, so I just tried it and it worked, at least in I4GL 4.11.UC1 >under SunOS 4.1.3. Danger Will Robinson! Danger Will Robinson! I just realized this the other day (even mentioned it, in my request for frequent periodic bug postings): A return statement in a report (in RDS only) causes the *next* row to be skipped as if it never existed. In the case of "data not found" I don't know if this is a problem (i.e., I don't know if it'll cause the first row of the next report to be lost or what). This is bug#20562, which I reported last week. (Say, do we get discounts on our next purchase for each bug we find? :-) [Actually, half serious -- it would encourage people to report their bugs; I found a few I just worked around because of the nuisance of slogging it out with tech support when I knew it was their bug. I only report things when I get truly stumped, which usually gives my brain the encouragement it needs to find the work-around. :-)] Anyway. Apparently it doesn't happen in i4gl, but in RDS it's what I'd consider a pretty serious bug. It doesn't bomb, no other symptoms, it merely silently skips the next "output to report". Unless you know your data quite well, it's hard to notice that a row is simply... missing. However, you can do what you're doing if you replace the 'return' with a 'goto' to the end of the report (yech). To wit: > 45 report rpt ( r_i, r_data_flag ) > 46 > 47 define > 48 > 49 r_i smallint, > 50 r_data_flag smallint > 51 > 52 output > 53 > 54 page length 10 > 55 top margin 1 > 56 bottom margin 1 > 57 > 58 format > 59 > 60 page header > 61 > 62 print "Page Header" > 63 skip 1 line > 64 > 65 on every row > 66 > 67 if ( not r_data_flag ) # if this is special "no data found" > 68 then # record, print message and return ##> 69 print "No data found" ##> 70 return #remove the print & return, replace with: goto leave > 71 end if > 72 > 73 print r_i # [assuming, also, that the "real" on-every-row material is more # than fits easily inside an 'else' to the first if; if it's really # as simple as "print r_i" then, of course, the code is cleaner to # do "if (r_data_flag) then print r_i else print "no data" end if", # so assume this would be undesirably ugly; then continue with: label leave: on last row print "No data found" > 74 > 75 page trailer > 76 > 77 skip 1 line > 78 print "Page Trailer" > 79 > 80 end report -- Andrew Burt aburt@du.edu "But if he was dying he wouldn't bother to carve "Aaaaargh", he'd just say it."