|
Simon, I agree with your arguments. I never used QCAPCMD before and had now a look to IBM's API docu. One question to your example snippet: You specified for optCtlBlk a LIKE(Qca_PCMD_CPOP0100). What is this reference data structure? Is it standard or your own built? Where is it located? I didn't find it in other command descriptions. Regards, Werner Noll -----Ursprüngliche Nachricht----- Von: Simon Coulter [mailto:shc@flybynight.com.au] Gesendet: Dienstag, 6. August 2002 01:31 An: rpg400-l@midrange.com Betreff: Re: Additional Error Specs from C-Proc. 'system' Hello Nelson, You wrote: >I've probably missed this in previous threads, but what is the value or >benefit of using the C 'system' over using QCAPCMD in the first place? Because it is simple and it allows literal strings to be used in an easier manner. For example, the following definitions: D int_t S 10I 0 D pointer_t S * D rc S LIKE(int_t) D system PR LIKE(int_t) EXTPROC('system') * * Required parameter group: * OS/400 command D command LIKE(pointer_t) VALUE D OPTIONS(*STRING) allow me to code: C callp system("DSPMSG") or C eval rc = system("DSPMSG") whereas using QCMDEXC with the following prototype: /if defined(LONG_PROC_NAMES) D QcaRunClCmd PR /else D QCMDEXC PR /endif D EXTPGM('QCMDEXC') * * Required parameter group: * A Control Language command string D clCmd 32702 CONST OPTIONS(*VARSIZE) * Length of command string D clCmdLen 15 5 CONST * * Optional parameter group: * A DBCS data flag D dbcsFlag 3 CONST OPTIONS(*NOPASS) requires: C callp QCMDEXC("DSPMSG" : 6) or D $CMD C CONST('DSPMSG') C callp QCMDEXC($CMD : %SIZE($CMD)) both of which are slightly uglier than system(). Using QCAPCMD is uglier still but much more powerful since its prototype looks like: /if defined(LONG_PROC_NAMES) D QcaProcessClCmd... D PR /else D QCAPCMD PR /endif D EXTPGM('QCAPCMD') * * Required parameter group: * Command string to process D clCmd 32702 CONST OPTIONS(*VARSIZE) * Length of command string D cmdLen 10I 0 CONST * Options control block D optCtlBlk LIKE(Qca_PCMD_CPOP0100) D CONST OPTIONS(*VARSIZE) * Length of options control block D optCtlBlkLen 10I 0 CONST * Format of options control block D format 8 CONST * Changed command string D chgClCmd 32767 OPTIONS(*VARSIZE:*OMIT) * Length provided for changed command string D chgClCmdLenProv... D 10I 0 CONST * Length available for changed command string D chgClCmdLenAvail... D 10I 0 * Error code D errorCode 1024 OPTIONS(*VARSIZE) In all the "ugly" cases the solution is to create a wrapper procedure that masks the ugliness behind a nice interface. For example: C eval errCode = runCLcmd("DSPMSG") where runCLcmd is a nice wrapper procedure that may in turn use either QCMDEXC or QCAPCMD or even system. I use system where I expect the command to succeed (e.g., DSPMSG is unlikely to fail) but I use the other methods when there is a reasonable chance of the command failing. However, if you take the effort to create a decent runCLcmd procedure you get the best of both worlds. Regards, Simon Coulter. -------------------------------------------------------------------- FlyByNight Software AS/400 Technical Specialists http://www.flybynight.com.au/ Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ Fax: +61 3 9419 0175 mailto: shc@flybynight.com.au \ / X ASCII Ribbon campaign against HTML E-Mail / \ -------------------------------------------------------------------- _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.