× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 4/27/2017 3:38 PM, Douglas Dunn wrote:
As another young developer just getting into iSeries, I promise
to only write new software with the modern techniques.
And I should probably get RDi. I am still curious about the old
fixed-form style, mainly because the syntax looks very exotic
to me. Can someone explain the concept of the
"cycle" that was mentioned about?

The RPG cycle, as hinted at, comes in several strengths. James is
talking about programs where the F-specification has a Primary file. To
my mind, the RPG version of 'Hello, World!' is exactly this sort of
program, once called an 80-80 list. It read 80 columns of data from a
card and wrote that same 80 columns of data to a printer. Read a card
and print it. Once at a time, until all the cards (records in the file)
have been read.

5770WDS V7R3M0 160422 IBM RPG/400
SEQUENCE
NUMBER *...1....+....2....+....3....+....4....+....5....+..
S o u r c e L i s t i n g
100 H* 80-80 LIST
200 H 1
300 FCARD IPE F 80 SEQ
400 FQSYSPRT O F 132 OF PRINTER
500 ICARD AA 01
600 I 1 80 DATA
700 OQSYSPRT D 1 01
800 O DATA 80
* * * * * E N D O F S O U R C E * * * * *

ovrdbf card buck/qrpgsrc mbr(hello)
call hello

000100170427 H* 80-80 LIST
000200170427 H 1
000300170427 FCARD IPE F 80 SEQ
000400170427 FQSYSPRT O F 132 OF PRINTER
000500170427 ICARD AA 01
000600170427 I 1 80 DATA
000700170427 OQSYSPRT D 1 01
000800170427 O DATA 80

Yeah, I just wrote it from scratch. And yeah, this stuff still compiles
and runs on 7.3. The next step up would be the use of level breaks.

5770WDS V7R3M0 160422 IBM RPG/400
SEQUENCE
NUMBER *...1....+....2....+....3....+....4....+....5....+....6.
S o u r c e L i s t i n g
100 H* COUNT SPECS IN AN RPG PROGRAM
200 H 1
300 FCARD IPE F 80 SEQ
400 FQSYSPRT O F 132 OF PRINTER
500 ICARD AA 01
600 I 18 18 SPEC L1
700 C ADD 1 COUNT 70
800 OQSYSPRT T 1 L1
900 O SPEC 1
1000 O COUNT JB 11

ovrdbf card buck/qrpgsrc mbr(hello2)
call hello2

H 2
F 2
I 2
C 1
O 3

The RPG-specific idioms here:
L1 on line 600. Indicates when the variable SPEC changes in value.

'70' on line 700 defines the variable COUNT on the fly as being 7 digits
long, no decimal places.

'T' on line 800 tells the compiler to only print this line at 'Total
Time' in the cycle; specifically when L1 is on.

'J' on line 1000 tells the compiler to edit the variable COUNT with
commas. Also, a '0' will print if the value is zero. Also, a '-' will
print if the value is negative. That's a lot of meaning in one letter!

'B' on line 1000 tells the compiler to blank the value of COUNT after
printing it. I could have done the same thing with the calculations by
using detail time L1.


The next step up would be multiple levels of level indicators, like for
example a sales report with totals by neighbourhood, city, county,
state, region, country, continent, planet, solar system... and I've
finally used all 9 level indicators! The Galactic Senate is going to
have to hire some more Bothans to collate the sales reports from the
various star systems...

I've deliberately left out the page headings, final totals, etc. in
order to keep it easy to read.

I'd have to do some work to show you matching record, because I'd need
to create a pair of tables, populate them, and then write the program.
I can't imagine there's much interest in seeing that, but it might be
fun to show how to convert that to SQL :-)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.