Title: Free Form RPG
1Free Form RPG
2Why Free Form? Cleaner More Structured Easier to
read Easier to code Indented Source Code Easier
to modify and maintain
3Must be running at least Version 5 Release 1 or
later
4Free directives go at postion 7 or 1st postion
to the right of the standard spec type /Free
and /End-Free code without a semicolon d
c /Free
/End-Free
5All variables must be defined in the D
Specs before c move
12345 Cust 5 now d Cust s
5 inz(12345)
6Op-Codes not supported ADD, ANDxx, CALL, CASxx,
COMPxx, CABxx, CAT, DEFINE, DIV, DOUxx, DOWxx,
GOTO, IFxx, MOVE, MOVEL, MOVEA, MOVE(P), MULT,
MVR, Orxx, PARM, PLIST, SCAN, SETOFF, SETON,
SUB, SUBST, SUBST(P), TAG, TESTB, TESTN, TIME,
WHENxx, Z-ADD, Z-SUB some are replaced with
BIFs (built-in-function)
7Changed Op-Codes ADD is now SUB
is now - DIV is now / MULT is
now CAT is now
8MOVE and MOVEL was move Dec Char now
ds d Char 4
d Dec
4 0 overlay(Char) or Char
CHAR(Dec) Char EDITC(DecZ)
9was move Char Dec now Dec
UNS(Char) (unsigned) also BIFs DEC, FLOAT,
INT valid statement Dec INT(1234.56)
10EVAL(optional) was c eval
C C 1 now C C 1 eval must be
used with extender eval(H) C B / A
11CALL was c call MyPgm
parm
MyParm now MyPgm(MyParm) or callp
MyPgm(MyParm) (must prototype)
12Prototypes Program Call d CustSrch pr
extpgm(CUSTSRCH) d Cust 5
const now call CustSrch(Cust) or callp
CustSrch(Cust) with 2 parms callp
CustSrch(CustCustName)
13Entry Prototype replaces Entry before c
entry plist
parm Cust now d Main
pr extpgm(MyPgm) d
5
d Main pi
d Cust
5
14All statements inside the /Free /End-Free tags
are ended with a semicolon Cust
12345 A statement can continue over several
lines if Cust lt gt 00000 and Cust lt
gt 99999 and Cust lt gt
15Klist not supported in /Free Klist now must be in
C Spec c Key Klist c KFld
Cust c KFld Inv /Free or
16new in V5 R2 BIF KDS d Key ds
likerec (MyFile Key) chain KDS(Key)
MyFile multiple key fields chain KDS(Key2)
MyFile
17Copy Books /copy bring code in as fixed
format must use /Free and /End-Free in the Copy
Book source
18Indention You may now indent your code for
readability
Item 12345 chain KDS(Key) InvnMst If
FOUND select when
Category 1 exsr
LoadCat1 when Category 2
exsr LoadCat2 endsl
endif
19Start out mixing Fixed Format and Free Format
this is valid c
move Date Today c
USA move Today AlphaDate
/Free dow inkc off do some
stuff enddo inlr on
return /End-Free
or
20/Free do loop exsr SRFixed
enddo inlr on /End-Free c SRFixed
begsr c movel
This is to Start Var c
endsr
21C Function h BndDir(QC2LE)
DftActGrp(NO) d CharToFloat pr
extpgm(ATOF) d Char 15
const d Dec
15 0 const now
call CharToFloat(CharDec) or callp
CharToFloat(CharDec)
22Web Sites http//www.ebisynetics.com/t _RPGtoFree
.htm http//www.linomasoftware.com/products /rpgt
oolbox/why-free.html http//publib.boulder.ibm.co
m/iseries /v5r1/ic2924/books/c0925073.pdf http//
ringsurf.com/netring?ringas400 webringactioninf
o
23Http//groups.yahoo.com search for
AS/400 http//groups.yahoo.com/group/RPGIV/ http
//groups.yahoo.com/group/eZ400/ http//home.allte
l.net/craigru http//www.scottklement.com http//w
ww.partner400.com