From: "Judson McClendon" Newsgroups: comp.os.msdos.djgpp,alt.comp.lang.learn.c-c++,alt.lang.basic References: <8E0A6B90Bjsampsonpostmasterco AT news DOT earthlink DOT net> <9APl3.1054$XG6 DOT 30509 AT dfiatx1-snr1 DOT gtei DOT net> <90_l3.4474$xN4 DOT 43628 AT news3 DOT mia> <7na84u$4d7 AT news3 DOT euro DOT net> <7nn6i2$9il AT news3 DOT euro DOT net> Subject: Re: A small bussiness billing application Lines: 56 X-Newsreader: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 Message-ID: Date: Wed, 28 Jul 1999 14:47:34 -0500 NNTP-Posting-Host: 209.214.108.101 X-Trace: news3.mia 933191217 209.214.108.101 (Wed, 28 Jul 1999 15:46:57 EDT) NNTP-Posting-Date: Wed, 28 Jul 1999 15:46:57 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Martijn Lievaart wrote: > >[1] For the cobol gurus out there, what does this peace of code do >(except for syntax errors, it has been a while since I wrote COBOL, >you'll get the meaning) > >PERFORM xxxxx VARYING I FROM 1 TO 9 > VARYING J FROM I+1 TO 10. This is COBOL 85 PERFORM statement format 4, written like this: PERFORM xxxxx VARYING I FROM 1 BY 1 UNTIL I > 9 AFTER J FROM I + 1 BY 1 UNTIL J > 10. However, you cannot use the expression (I + 1) there in standard COBOL 85; it must be a numeric literal, data name or index name. Unfortunately, the new draft standard CD 1.5 does not permit it either. I would like to see COBOL accept numeric expressions anywhere it will accept numeric literals or variables. A logically equivalent but correct syntax is: PERFORM VARYING I FROM 1 BY 1 UNTIL I > 9 ADD 1 I GIVING TEMP PERFORM xxxxx VARYING J FROM TEMP BY 1 UNTIL J > 10 END-PERFORM. It performs paragraph (or section) xxxxx 81 times, with the following values for I and J: I J -- -- 1 2 1 3 ... 1 9 1 10 2 3 2 4 ... 2 9 2 10 3 4 ... 9 9 9 10 Just the logic you would use for a bubble sort. :-) -- Judson McClendon judmc123 AT bellsouth DOT net (remove numbers) Sun Valley Systems http://personal.bhm.bellsouth.net/~judmc "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."