|
For starters, when interacting with a display file, I usually use numbered indicators, but never in the conditioning indicator slot (pos 9-11). I evaluate then with IF, i.e C If *In99 * Stuff C EndIf You can also rename your numbered indicators. I believe if you search this list for 'rename indicators', you can find an example, if not, I will provide one that was given to me. But to answer your question, if you want your code to look 'beautiful' (I prefer 'sexy'), then there are a few things to consider -- keep in mind that everyone has their own opinion on these matters, but here are a few of mine. 1) You don't have to use upper case anymore! But don't use all lower case -- Personally, I use mixed case -- I usually capitalize the first letter of OP codes (Chain, Open, etc.), and even sometimes capitalize other letters, for emphasis (ReadE, SetLL, etc.) 2) Use the If/Else/ElseIf operators instead of ones like IFEQ, IFGT, ANDNE, etc. 3) When turning an indicator on, you can use Eval instead of SETON. i.e. C Eval *In99=*On 4) Use blank lines instead of C-spec comment lines. This is allowed, and seems to make code easier to read. 5) Use prototyping for your program, instead of *ENTRY PLIST. This puts the parameters your program works with in the D specs, and is easier to read. 6) Use structured programming techniques. What I mean here is, use Dow/Dou/Do loops instead of TAG/GOTO operations. This tends to make the code look nicer, and they (the voices in my head) tell me that it is better to use structured programming techniques. 7) Also, you might try to use subprocedures instead of subroutines. These are more powerful, while the subroutine you listed is pretty straight forward, you might try your hand at a few subprocedures to see if you like them better. 8) Try out free format calc specs. (/Free, /End-Free). In my opinion, you can get pretty fancy-looking with indenting and such. Just my opinions. Good Luck! On Thu, 11 Nov 2004 02:27:53 +0530, Muralidhar Narayana <muralidhar_narayana@xxxxxxxxxxx> wrote: > Hi > I have written programs CLP&RPGLE to give an option to User to select Yes/No > options. > Yes option will give him print and No option will send an email to him. > Can some one try to advise me on how can I eliminate indicators and replace > with builtin functions in my code, is there anyway still i can reduce my > code...if possible pls answer..this code what I ve written is working for me > but nt looking beautiful.. > ======================= > YYESNOC:CLP > ------------------ > PGM PARM(&YESORNO) > 0004.04 DCL VAR(&YESORNO) TYPE(*CHAR) LEN(1) VALUE(N) > 0005.00 DCL VAR(&REPLY) TYPE(*CHAR) LEN(1) > 0007.00 CALL PGM(YYESNOR) PARM(&REPLY) > 0008.00 IF (&REPLY *EQ 'Y') THEN(DO) > 0009.00 CHGVAR VAR(&YESORNO) VALUE('Y') > 0010.00 ENDDO > 0011.00 IF (&REPLY *EQ 'N') THEN(DO) > 0011.01 CHGVAR VAR(&YESORNO) VALUE('N') > 0013.00 ENDDO > 0014.00 > 0015.00 ENDPGM > ---------------------- > YYESNOR:RPGLE : > FYYESNO CF E WORKSTN > 0005.00 C MOVE 'N' REPLY > 0006.00 C AG1 TAG > 0007.00 C *ENTRY PLIST > 0008.00 C PARM RPLY 1 > 0009.00 C EXFMT DSPLY > 0010.00 C SETOFF 99 > 0011.00 C *IN03 IFEQ '1' > 0012.00 C GOTO BOTTOM > 0013.00 C ELSE > 0014.00 C EXSR VALID > 0015.00 C N99 MOVE REPLY RPLY > 0016.00 C 99 GOTO AG1 > 0017.00 C END > 0018.00 C BOTTOM TAG > 0019.00 C** > 0020.00 C MOVE '1' *INLR > 0021.00 C** > 0022.00 C***************************************************************** > 0023.00 C* SUBROUTINE TO VALIDATE REPLY ENTERED ON SCREEN ** > 0024.00 C***************************************************************** > 0025.00 CSR VALID BEGSR > 0025.01 C REPLY IFEQ ' ' > 0025.02 C MOVE 'N' REPLY > 0025.03 C ENDIF > 0026.00 C REPLY IFNE 'Y' > 0027.00 C REPLY ANDNE 'N' > 0028.00 C REPLY ANDNE 'y' > 0029.00 C REPLY ANDNE 'n' > 0030.00 C *IN03 ANDNE '1' > 0031.00 C SETON 99 > 0032.00 C END > 0033.00 CSR ENDSR > > -- > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > > -- "Enter any 11-digit prime number to continue..."
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.