I don't know about the most common method, but most CL code that I have seen
seem to omit the keyword, except where necessary.
Personally, however, I always use the prompter for two reasons.
First, I rarely remember the sequence of the keywords, even for frequently
used things like OVRDBF.
Second, I find the code more readily readable with the keywords (see #1).
Third, I want people to be able to easily understand my code. (I know, I
said two; I lied.)
I, also, try to line up things. For example, a string the DCLs will all
have the TYPE() LEN() and VALUE() keywords in the same columns. For me it's
easier to read than zigzagging through the definitions. Same for repeating
commands, such as CHGVAR if there are 2-n in a row. For what it's worth, I
do the same kind of alignment when doing EVALs in free format RPG.
Another thing: I always put the '+' for continuations in column 75, unless
the break is in the middle of a literal. Again, just easier to read.
I'll beg off on the etiquette question because I used to do the same thing
(prompt) to other programmers' CL at the software company, but only when I
had to change the line (see #1). I might, also, have to prompt to
understand which keyword was being defined, but just exited the prompter in
those cases (I think).
Jerry C. Adams
IBM i Programmer/Analyst
"Female Adelie Penguins Acquire Nest Material from Extrapair Males After
Engaging in Extrapair Copulations" - paper in the journal Auk (vol. 115, No.
2) by F.M. Hunter and L.S. Davis (i.e., they prostituted themselves for
rocks)
--
A&K Wholesale
Murfreesboro, TN
615-867-5070
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Tuesday, May 29, 2012 9:36 AM
To: midrange-l@xxxxxxxxxxxx
Subject: CL code formatting and programming etiquette
When you create CL code, do you try to make it easy to read ie use lower
case; add some white space, skip keywords such as COND and VAR and THEN, and
line things up?
Like this:
select
when (&reportID = 'LS') goto report_LS
when (&reportID = 'SR') goto report_SR
when (&reportID = 'SB') goto report_SB
otherwise goto endpgm
endselect
report_LS:
chgvar &TITLE1 'New Customer Report'
chgvar &TITLE2 'Trader Notification'
chgvar &SHOWCUST 'N'
chgvar &QRYSLT (&QRYSLT *bcat ' ASHPSTS = +
"UT" *and ASLSCNT = 0 *and ACTMDTR = "R"')
******************************************************
Or
******************************************************
Do you run everything thru the prompter, like this:
select
WHEN COND(&REPORTID = 'LS') THEN(GOTO +
CMDLBL(REPORT_LS))
WHEN COND(&REPORTID = 'SR') THEN(GOTO +
CMDLBL(REPORT_SR))
WHEN COND(&REPORTID = 'SB') THEN(GOTO +
CMDLBL(REPORT_SB))
OTHERWISE CMD(GOTO CMDLBL(ENDPGM))
ENDSELECT
report_LS:
CHGVAR VAR(&TITLE1) VALUE('Loaded Cars Available +
for Sale')
CHGVAR VAR(&TITLE2) VALUE('Trader Notification')
CHGVAR VAR(&SHOWCUST) VALUE('N')
CHGVAR VAR(&QRYSLT) VALUE(&QRYSLT *BCAT ' ASHPSTS = +
"UT" *and ASLSCNT = 0 *and ACTMDTR = "R"')
Which method is preferred or more widely used?
I always do the former (mixed case, skip keywords).
A co-worker goes thru my code and prompts it all into the harder-to-read
(imo) ALL CAPS stuff.
Is this following IT etiquette?
I realize people alter other's code over the years. But this is happening
prior to initial promotion.
Does such an etiquette concept exist in the IT development field?
______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs
Skyscan service.
For more information please visit
http://www.symanteccloud.com
______________________________________________________________________
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.