On 12/01/2010, at 1:27 AM, Vern Hamberg wrote:
Using subprocedures - in fact, this might be better justification for
making everything free.
Ah ... I was thinking of multiple occurrences of /FREE and /END-FREE
within the body of C-Specs; not just at the start and end of each
block of C-Specs. I don't find coding /FREE and /END-FREE around a
procedure body particularly onerous or ugly but I certainly wouldn't
mind if I didn't have to do that.
The solution is not a fully free-form RPG but rather an H-Spec that
indicates all C-Specs will be free-form e.g., CSPEC( *FIXED | *FREE ).
*FIXED is the default and gives current behaviour. *FREE simply
implies /FREE before the first C-Spec and /END-FREE after the last C-
Spec. The first C-spec is the occurrence of a line where columns 6 & 7
are empty and a valid op-code is found. The last C-Spec of a group is
given by the occurrence of a specification identifier.
The compiler can add the /FREE and /END-FREE while reading the source
to make parsing easier.
Further, this H-Spec keyword should not preclude the user adding /END-
FREE and /FREE as required if they need to drop out of free-format for
some operation. This would be similar behaviour to file open handling.
Even without USROPN I can CLOSE and OPEN a file.
Thus:
H CSPEC(*FREE)
H DFTACTGRP(*NO) ACTGRP(*CALLER)
D proc1 PR 5I 0
D parm1 10 CONST OPTIONS(*NOPASS)
D proc2 PR 5I 0
D parm1 10 OPTIONS(*OMIT)
D proc3 PR 5I 0
D parm1 10 OPTIONS(*NOPASS:*OMIT)
CALLP proc1;
CALLP proc2(*OMIT);
CALLP proc3;
EVAL *INLR = *ON;
RETURN;
P proc1 B
D proc1 PI 5I 0
D parm1 10 CONST OPTIONS(*NOPASS)
IF %PARMS > 0;
ENDIF;
/END-FREE
C NEEDLE:X SCAN HAYSTACK:Y FOUND
/FREE
RETURN 1;
P proc1 E
P proc2 B
D proc2 PI 5I 0
D parm1 10 OPTIONS(*OMIT)
IF %PARMS > 0 AND %ADDR(parm1) <> *NULL;
ENDIF;
RETURN 2;
P proc2 E
P proc3 B
D proc3 PI 5I 0
D parm1 10 OPTIONS(*NOPASS:*OMIT)
IF %PARMS > 0 AND %ADDR(parm1) <> *NULL;
ENDIF;
RETURN 3;
P proc3 E
In fact, I thought something similar had already been proposed for RPG.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.