"...remember that ALL commands call a program. Don't believe me? Try DSPCMD IF."

Umm, no external program is run when a CL program "processes" commands like IF, GOTO, CHGVAR, DOUNTIL, DOWHILE, DOFOR, SELECT, WHEN, ENDDO, etc. For example, the IF command's CPP is QCLIF, however that program doesn't exist. The GOTO command's CPP is QCLGOTO; likewise that program doesn't exist. You get the point.

It shouldn't take much thought to realize why. When the CL compiler encounters these commands it just substitutes the necessary code, such as a branch instruction in place of the GOTO command.

So, not ALL commands actually call a program, but most do.

Here's something to try which proves this. Create a duplicate object of the GOTO command and call it BRANCH (or anything you want). Create a CL program that uses the BRANCH command to skip over some other command. Delete the BRANCH command and then run the program. It will still work. I created the following to test this and, as expected, the delay did not happen.

Branch CmdLbl(EndPgm)
DlyJob 300
EndPgm: EndPgm

For years (since 1987) I used duplicates of the GOTO command called EXSR and ENDSR to provide pseudo-subroutines in CL using a "stack", a "stack pointer", a link section, and a lot of labels. It made it much easier to code and maintain programs that had loops within loops, such as processing a list of files and then processing a list of members for each file. This was long before we had real subroutines and looping constructs in CL, which we didn't get until 2004 or so.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Monday, September 10, 2012 10:08
To: Midrange Systems Technical Discussion
Subject: Re: program to read pf in reverse order using cl/400 program

Honestly, file processing in CL is limited. It can be done but why would you? To do this requires you call another program. Before anyone differs with me, remember that ALL commands call a program. Don't believe me? Try DSPCMD IF. Whether or not IBM supplies the program is a different matter.

Now as to your solution...
You could use the RUNSQL command that came out with TR4 in 7.1 to create a new file sorted in that order.
RUNSQL SQL('create table qtemp/crap as (
select * from erplxf/rco order by rrn(rco) desc) with data')
then you could process that table.
CL doesn't yet support imbedded sql, (like rpg does). Otherwise you could drop the create table and process that directly.

Rob Berendt
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755

This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page