Indent Free-RPG program

page d'accueil
Boite à outils

Cette page a été mise à jour le 14 septembre 2009
Contact

Welcome page
Tools box

 

Attention : identified bug on indenting SQLRPGLE which sql field name in mixed case. They are lowered.

Versionning :

last version : How to upload to my 400

CHGPFM FILE(JPLTOOLS) MBR(INDENTC ) SRCTYPE(CLLE ) EXPDATE(*NONE) SHARE(*NO) TEXT('Having RPG Free progs correctly indented ') 
CHGPFM FILE(JPLTOOLS) MBR(INDENTLE ) SRCTYPE(RPGLE ) EXPDATE(*NONE) SHARE(*NO) TEXT('Having RPG Free progs correctly indented ')

CRTCLMOD MODULE(INDENTC) SRCFILE(QPGMSRC) DBGVIEW(*ALL) ENBPFRCOL(*FULL)
CRTPGM PGM(INDENTC) BNDDIR(QC2LE) ACTGRP(JPLTOOLS)

CRTSRCPF FILE(INDENTW) RCDLEN(112) TEXT('IndentLE temp src file')
CRTRPGMOD MODULE(INDENTLE) SRCFILE(JPLTOOLS) OPTION(*NODEBUGIO *SRCSTMT *SHOWCPY *SECLVL *EXPDDS) DBGVIEW(*ALL) REPLACE(*YES)ENBPFRCOL(*FULL)
CRTPGM PGM(INDENTLE) BNDDIR(QC2LE) ACTGRP(JPLTOOLS)

PDM option : IN = CALL PGM(INDENTC) PARM(&F &L &N &S)
Cet outil permet de numéroter les boucles RPG. Un de plus. Celui-ci a une fantaisie supplémentaire : il indente les boucles en code Free-RPG de 3 caractères, ce qui en améliore fortement la lisibilité : voir le code du programme

Liste des fonctions sur le code Free-RPG :

  • Indente chaque boucle de 3 caractères (constante IndentSize)
  • change la couleur des commentaires
  • ne change rien aux lignes contenant une quote
  • indente les lignes RPG splittées
  • compresse les espaces en trop
  • distingue les procédures (boucles de niveau 00)
  • distingue les sous-programmes (boucles de niveau 1)
  • garanti que le code reste entre les colonnes 8 et 80
  • garanti que code + commentaire reste entre les colonnes 8 et 100
Option "no sql indent"
Pour empecher INDENTLE de toucher du code SQL,  ajouter le commentaire "no sql indent" sur la ligne exec sql : exemple :
exec sql // no sql indent
This tool permits to number the RPG loops. One more. This one has a supplementary fantasy: it indents the loops in Free-RPG code of 3 characters, what improves the readability strongly. Look at  the code of the program

List of the functions on the Free-RPG code: 

  • Indente each loop of 3 characters (IndentSize constant) 
  • change the color of the comments 
  • don't change anything to the lines containing a quote 
  • indent the splitted RPG lines
  • remove the doubled spaces
  • distinguish the procedures (level 00 loop) 
  • distinguish the subroutines (level 01 loop) 
  • guaranteed that the code stay between the columns 8 and 80 
  • guaranteed that code + comment stay between the columns 8 and 100
Option "no sql indent"
To stop INDENTLE from touching the SQL code, add the comment" no sql indent " on the exec sql line: example: 
exec sql / / no sql indent

/* -
Having RPG Free progs correctly indented -
-
purpose: -
-
when writing rpg free programm, you can indent your code to -
obtain code very easy to read. This utility improve a common -
tool to add indentation of the free code, even mixed with C -
cards (i.e., it works also with SQLRPGLE) -
-
rules : -
-
* column 1 to 3 is reserved for "if" numbering quite like rpg compiler in listing : -
set at 1 -
'B' for begin of loop (if, do, select, ...) -
'X' for invert loop (else, when, ...) -
'E' for end of loop -
set at 2-3 the loop deepness -
* in fix format, -
- take care of table load at compil time (** at 1-2) -
- set x'22' (=white) at 5 if 7=* -
* in free format -
- start code at 7 -
- add 3 spaces for each level of deepness -
-
PDM option : (STRPDM then 3 then F16) -
IN CALL PGM(INDENTC) PARM(&F &L &N &T) -
-
-
*/

The source code is provided as an open source tool under the GNU General Public License, version 2.  In summary, this license specifies:

By clicking the download link you acknowledge and agree to the terms of the license.

Download the (zipped) SAVF containing the JPLTOOLS : the source file, the message file, the bnddir

THIS TOOLBOX IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS TOOLBOX, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.