Return to the RPG Tips
How to create your own built-in functions
Here is a quick, trivial example of implementing a service program that is meant to be called from other programs... At the bottom of this message will be 4 source members. ** Source Member: SILLYSRV_H ** Purpose: Defines prototypes for use with SILLYSRV ** D SillyProc PR D Message 50A const ** Source member: SILLYSRV ** Purpose: Source for module "SILLYSRV" which will be made ** into a service program of the same name. ** ** To compile: ** 1) CRTRPGMOD SILLYSRV SRCFILE(xxx/QRPGLESRC) DBGVIEW(*LIST) ** 2) CRTSRVPGM SILLYSRV MODULE(SILLYSRV) EXPORT(*ALL) ** H NOMAIN D/COPY QRPGLESRC,SILLYSRV_H P SillyProc B Export D SillyProc PI D Message 50A const c Message dsply Pause 1 c return P E ** Source Member: COOLPGM ** Purpose: To demonstrate the use of SILLYSRV ** ** to compile: ** 1) First make sure SILLYSRV has been compiled. ** 2) CRTRPGMOD COOLPGM SRCFILE(xxx/QRPGLESRC) DBGVIEW(*LIST) ** 3) CRTPGM COOLPGM BNDSRVPGM(SILLYSRV) ** ** D/COPY QRPGLESRC,SILLYSRV_H C callp SillyProc('Testing the SillySrv *SRVPGM') c eval *inlr = *on /** Source Member: COOLPGM2 + ** Purpose: To demonstrate, once again, the use of the + ** SILLYSRV service program. + ** + ** to compile: + ** 1) Make sure SILLYSRV has already been created. + ** 2) CRTCLMOD COOLPGM2 SRCFILE(xxx/QCLSRC) DBGVIEW(*LIST) + ** 3) CRTPGM COOLPGM2 BNDSRVPGM(SILLYSRV) + ** */ pgm DCL VAR(&message) TYPE(*CHAR) LEN(50) CHGVAR VAR(&message) VALUE('Its not that easy being + greenscreen!') CALLPRC PRC(SillyProc) PARM(&message) endpgm
[report a broken link by clicking here]