× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks Barbara.  I know using the %Trim is overkill (overcautious by
nature LOL) & I usually do code with RUN(CmdStr:%Len(CmdStr)) .


Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Wednesday, September 07, 2005 1:44 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Executing Commands within an RPG program

Holden Tommy wrote:
> 
> OR you could use QCMDEXC instead of worrying about ACTGRP...
> 
>  * Run CL Commands Procedure...
>  * To use this functionality use the CALLP opcode
> DRun              PR                  ExtPgm('QCMDEXC')
> D CmdStr                      3000A   Const Options(*VarSize)
> D CmdLen                        15P 5 Const
> D CmdDBCS                        3A   Const Options(*NoPass)
>  * This are work fields used as parms for the procedure
>  * After you load the Cmd field use Eval CmdStrSize=%LEN(%TRIM(CMD))
>  *   The call will look like this CALLP   RUN(CMD:CMDSTRSIZE)
> DCmdStr           S           3000A   Inz Varying
> DCmdStrSize       S              4P 0 Inz
>  * End Of Run CL Commands Procedure...
> 

You can simplify the calling code, and remove the CmdStrSize definition:

   eval cmdStr = 'ovrprtf  ... '
   callp run(cmdStr : %len(cmdStr))

(Since you used CONST on the prototype, you can code %len directly, and
since you used VARYING on the definition of CmdStr, you don't need the
%TRIM to get the length.)

I agree that using QCMDEXC is better in this case, since it doesn't have
any of side effects that changing the activation group might have.

Anyway, in general, I like QCMDEXC better than system() anyway, because
of way system() handles error messages, even if system() is easier to
call having only the command parameter.  I don't like the way the
message automatically gets taken out of the joblog.  Also see rob's post
in the recent thread "Using CL to call RPG pgms"
http://archive.midrange.com/rpg400-l/200509/msg00149.html.

--
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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.