Useless use of division

runrig on 2003-02-20T23:26:27

Noticed this sort of thing several times over while editing a 4gl report:

if rpt.value/1000 < 0 then
  print 0
else
  print rpt.value/1000
end if
On another note, I wonder how much demand there would be for 4gl-like text report module in perl, with things like page headers and trailers, group headers and trailers, among other things. Back when I was first looking at perl formats, these were the things I was missing, and now I finally might be ready to code such a thing. Or is there something on CPAN I'm just not seeing yet?

Then again, a co-worker says I should just skip plain text reports and go straight to something more Crystal Reports-like, but I don't know where I'd start there (XML FO's? How to tell where to print page trailers w/variable fonts? etc).


useless report

kjones4 on 2003-02-21T00:06:55

So rpt.value can't be negative? Maybe they wanted to report negative values as 0.

Re:useless report

runrig on 2003-02-21T00:32:09

The useless part is in the boolean section of the 'if' statement. It's not a real big deal, but I haven't seen a number yet that flips its sign when you divide by a positive number. Unless you overload '/', but let's not get into that, and you can't do it in this 4gl anyway :-)

Re:useless report

kjones4 on 2003-02-21T03:15:57

Ya, I guess if they wanted to report a 0 if some number was negative, then they didn't need to do the division.

Need for a 4GL like PRG

htoug on 2003-03-28T10:16:14

A Perl Report Generator - somewhat like format, but with headers and footers, and breaks and running sums and ...[takes a firm grip on himself and tries to remain calm]

I would just love it!

It should be possible already, The Damian is probably doing a proof of concept - or will soon, as promised in apocalypse 7 (look at the very end of the page).