September 25

REVCLSRC – Revamp CL Source

[thrive_headline_focus title=”Revamping Control Language Source Code” orientation=”left”]

Q: What does Revamping mean?

A: Give it a polish up or making it spiffy as my Nana used to say!

For CLLE and CLP programs this basically means that we can use the REVCLSRC command to stream through our source code and spiff up the soure layout by doing things like –

  • switching all the code to lower case
  • or (of course) upper case
  • re-parsing each command line and making it cleaner to read
  • indent all DO/ENDO loops
  • tell us if we have any missing ENDO statements

Here is a quick example of some code before and after cleaning:

UGLY CODE

/* this is an ugly example of some dodgy CL Code */ 

PGM PARM(&curhotfix &library &linefailed) 

COPyRiGhT text('| HOTFIX733 2017.07.31') 
DCL VAR(&CURHOTFIX) + 
TYPE(*CHAR) + 
           LEN(10) 
       dcl var(&library) type(*char) len(10) 
       dcl var(&linefailed) type(*lgl) len(1) 
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(UNMONERROR)) 
 CHGVAR VAR(&LINEFAILED) VALUE('0') 
CHKOBJ OBJ(&LIBRARY/RLL11) OBJTYPE(*FILE) 
 monmsg cpf0000 exec(do) 
         CRTDUPOBJ OBJ(RLL11) FROMLIB(&curhotfix) + 
 OBJTYPE(*FILE) TOLIB(&library) TRG(*NO) 
         enddo 
  call pgm(tmovrll11)     parm(&curhotfix &library) 
                                     return 
                                     unmonerror: + 
 chgvar var(&linefailed) value('1') 
endpgm 

Run the REVAMP CL SRC (REVCLSRC) command

REVCLSRC SRCMBR(mymember) 
 SRCFILE(mylib/myfile) 
 CVTCASE(*LOWER)

and end up with:

UGLY* BUT CLEAN CODE

/* this is an ugly example of some dodgy CL Code */ 

pgm parm(&curhotfix &library &linefailed) 

copyright text('| HOTFIX733 2017.07.31') 
dcl var(&curhotfix) type(*char) len(10) 
dcl var(&library) type(*char) len(10) 
dcl var(&linefailed) type(*lgl) len(1) 
monmsg msgid(cpf0000) exec(goto cmdlbl(unmonerror)) 
chgvar var(&linefailed) value('0') 
chkobj obj(&library/rll11) objtype(*file) 
monmsg cpf0000 exec(do) 
crtdupobj obj(rll11) fromlib(&curhotfix) objtype(*file) + 
tolib(&library) trg(*no) 
enddo 
call pgm(tmovrll11) parm(&curhotfix &library) 
return 
unmonerror: + 
chgvar var(&linefailed) value('1') 
endpgm

* I didnt say it was a RMVUGLYCODE did I? That command is in development  🙂


Tags

REVCLSRC


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

Name*
Email*
Message
0 of 350
>