Hi Mark,

I'll have to fire up the machine in the back room and grab some source code
off of that...  I have to put it back together first - had to use it as a
test box when I built my last PC and never got it slapped back together.

But basically from memory it's something like:
GOSUB OPEN.AND.INIT
IF NOT(ERROR) THEN
  GOSUB DO.IT.ALREADY
END
GOSUB PRINT.GRAND.TOTALS
GOSUB FINISH.UP
STOP
DO.IT.ALREADY:*
PERFORM 'SELECT SOD BY CUSTOMER BY DIVISION'
SELECTED = @SYSTEM.RETURN.CODE
IF SELECTED < 1 THEN
  PRINT 'Dooooohhhh!'
  RETURN
END
FIRST = 1
LOOP
  READNEXT SOD.ID ELSE
    GOSUB PRINT.CUSTOMER.TOTALS
    GOSUB PRINT.DIVISION.TOTALS
    EXIT
  END
  GOSUB READ.ORDER.LINE
  IF ERROR OR NOT.OPEN.LINE THEN CONTINUE
  IF FIRST THEN
    FIRST = ''
    SAVED.CUST = CUSTOMER
    SAVED.DIVISION = DIVISION
  END
  GOSUB ADD.TO.GRAND.TOTALS
  IF SAVED.CUST = CUSTOMER THEN
    GOSUB ADD.TO.CUSTOMER.TOTALS
  END ELSE
    GOSUB PRINT.CUSTOMER.TOTALS
    SAVED.CUST = CUSTOMER
    GOSUB ADD.TO.CUSTOMER.TOTALS
  END
  IF SAVED.DIVISION = DIVISION THEN
    GOSUB ADD.TO.DIVISION.TOTALS
  END ELSE
    GOSUB PRINT.DIVISION.TOTALS
    SAVED.DIVISION = DIVISION
    GOSUB ADD.TO.DIVISION.TOTALS
  END
REPEAT
RETURN

EASY AS PIE! (3.14159)  ;-)

Important to note that the clearing of the total variables is at the end of
the printing during the controlled break.  Also important is that after
printing totals, and clearing the total vars, that the saved customer or
saved division is 'bumped up' to the current value, and then after that they
current record gets added to the totals so as to not loose any data.

The order of processing the lowest level sub-set is necessary as that is how
it is to appear on the report, i.e. lines of customer totals, followed by a
division total, and then more customers and divisions until the grand.  Note
that we also want to print the customer and division totals after the last
record or the last customer and division will never make it to the report.

Of course it's always nice to throw in a screen graph for big files so users
can see how long a coffee break to take....

This style is directly from the book I mentioned and is referred to as
"Controlled Break" processing.

I'm shutting down early for the day, since I like to get a early start on
the weekends.  Gonna go marinate a nice usda choice sirloin, and get that
grill warmed up!!!!  :)

        *=aee=*

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Mark Johnson
Sent: Friday, June 18, 2004 7:17 AM
To: [EMAIL PROTECTED]
Subject: Re: [U2] [UV] WHILE READNEXT id DO


Was the new release an OS or application level. The OS should have had no
problem.

My MVquery example is certainly do-able at TCL. I would like to see it in a
LOOPed environment, verbatim. Usually reports get so complex that they
exceed the query level and have to be done at the program level. We all know
when we turn that corner of exceeding the query level on a report's design.

thanks.

----- Original Message -----
From: "Allen E. Elwood (CA)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 17, 2004 9:57 PM
Subject: RE: [U2] [UV] WHILE READNEXT id DO


> Hi Mark,
>
> GOTO-phobia (love that term :-) Don't know about you, but I have seen
> programs that were 5000 lines long, filled with goto's that needed
upgrading
> to fit a new release and required hundreds of hours to upgrade instead of
> 20.  When done, they became very 'quirky' and impossible to debug.
Finally
> after user complaints, 400 hours were invested to completely rewrite.  And
> at $175 per hour, 400 hours is a big loss to a software house - "blood on
> the highway" as the owner used to say. So whereas goto's are not 'bad',
bad
> programming is VERY bad.
>
> Usually with sorts I just form the key that defines the break-points after
> every read.  The first time through you prime the key and kill the first
> flag, after that when the key changes you print the totals, set the key to
> the value that caused the break, clear the totals while adding to the
grand
> total(s) and then add the values for the current record to the just
cleared
> totals and voila.  Done deal !  Nest this logic and you can do
> multi-sort-breaks.  I learned this method very well as before I came to
the
> Pick community (as it *used* to be called) I was working on a system that
> had no query language.  And the CEO was a big believer in sales analysis
> reports of every imaginable sorts.  Plus, every once in a while you run
into
> someone that wants the a column for "This division sales percent of the
> territory total" and "This territory sales percent of the Grand Total",
etc.
> which are pretty much impossible without programming.
>
> That said, I still believe in using Uniquery for reports as much as
> possible.  Keep is simple whenever possible!
>
> But, really when you get down to it, it just doesn't really matter how you
> get something done.  It's the analytical mindset, business experience and
> attention to details that really make a good programmer.  IMHO!
>
> Allen
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Mark Johnson
> Sent: Thursday, June 17, 2004 5:12 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [U2] [UV] WHILE READNEXT id DO
>
>
> Very good question. Is BASIC Structured. And who defines the structures.
>
> I was on a phone interview with a prospective employer a few years ago and
> during that conversation he brought up the concept of GOTO's. I completely
> understand GOTO's (most on this forum are GOTO-phobic) and use them
> sparingly.
>
> That turned the tide of the interview. Despite my 20+ years (at that time)
> of MV programming, he couldn't get off the GOTO-less soapbox. Since the
> interview got a little pissy towards the end, I asked him if he ever drank
a
> beer. His yes answer then allowed me to label him an alcoholic as clearly
> alcoholics drink beer.
>
> Do GOTO's make one a poor programmer or do poor programmers use GOTO's.
I've
> seen a lot of GOTO-less code that is very sloppy with its over-use of
FLAGS
> to skirt around code sections. I've also seen well written code with a few
> GOTO's placed in appropriate places.
>
> This appears to be the semi-annual GOTO holy war. I'm capable of learning
so
> I would like for someone to offer me some code segments to perform the
> following MVquery statement as a true data/basic program:
>
> SORT CUSTOMER BY STATE BY CITY NAME BREAK-ON CITY BREAK-ON STATE TOTAL
> YTD-SALES
>
> I really would like to see how the other side programs this.
>
> thanks in advance.
>
> ----- Original Message -----
> From: "Glenn Herbert" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 17, 2004 3:00 PM
> Subject: RE: [U2] [UV] WHILE READNEXT id DO
>
>
> > Is BASIC structured? :-p
> >
> > If your answer is yes, then the GOTO should probably not be allowed
> (except
> > in rare cases).
> >
> > If your answer is no, then GOTO away!! (caveat: if not abused!)
> >
> > As Yoda says:  GOTO is the evil not; incorrect the usage is!
> >
> > At 02:46 PM 6/17/2004, you wrote:
> > >You realize this does not conform to the ANSI structured programming
> > >principles?  I have a version dated 1982 and goto's are not allowed...
> > >
> > >Or was this just a joke?  In which case you certainly got me!  :-)
> > >
> > >-----Original Message-----
> > >From: [EMAIL PROTECTED]
> > >[mailto:[EMAIL PROTECTED] Behalf Of Simon Lewington
> > >Sent: Thursday, June 17, 2004 11:02 AM
> > >To: [EMAIL PROTECTED]
> > >Subject: Re: [U2] [UV] WHILE READNEXT id DO
> > >
> > >
> > ><[EMAIL PROTECTED]> ...
> > > > LOOP
> > > > code
> > > > WHILE READNEXT id DO
> > > > more code
> > > > REPEAT
> > >
> > >I prefer:
> > >
> > >100
> > >[code]
> > >GOTO 300
> > >200
> > >[more code]
> > >GOTO 100
> > >300
> > >READNEXT ID THEN GOTO 200
> > >-------
> > >u2-users mailing list
> > >[EMAIL PROTECTED]
> > >To unsubscribe please visit http://listserver.u2ug.org/
> > >-------
> > >u2-users mailing list
> > >[EMAIL PROTECTED]
> > >To unsubscribe please visit http://listserver.u2ug.org/
> > -------
> > u2-users mailing list
> > [EMAIL PROTECTED]
> > To unsubscribe please visit http://listserver.u2ug.org/
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> To unsubscribe please visit http://listserver.u2ug.org/
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to