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



If you truly want to call this program from command entry (and I don't
understand why since you can run commands directly from command entry) then
it should be wrapped in a CMD definition. That's what those things were
invented to handle.


Bob Cozzi
Cozzi Consulting
www.rpgiv.com


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Bill Hopkins
Sent: Friday, November 07, 2003 7:33 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Junk Passed 32 on 3000A parm

I call with this from command line 
CALL PGM(TESTQCMD) PARM('CALL PGM(FORCASTX)ENDCMD')

When looking at code in Debug I see "garbage" in parm after 32A or after 
where command ends. "It's actually not garbage, but rather it's memory 
that you aren't supposed to
be using" Sorry was trying to explain to someone off list, should have 
taken it more technical but hey I'm a "High Tech Red-neck" so sometime you 
get "junk and garbage" for replacement terms :). But speaking of 
replace..... 

I get the start position of "ENDCMD" with %scan returning value of 19 
where E of ENDCMD is located in cmd parm which looks like this.... CALL
PGM(FORCASTX)ENDCMD         o    CALLf    PGMØ    '
o    TESTQCMDf    PARMØ    E    CALL PGM(FORCASTX)ENDC'
MD»                                                         '
                                                            '
                                                            '. 
Then comes the %replace 
%REPLACE(replacement string: source string{:start position {:source
length to replace}})

1)Replacement string is a blanks ' '
2)Source String is the cmd parm field with "garbage" oops "rather it's 
memory that you aren't supposed to be using" past 32A parm length. 
3)Start Position for replace is set to 19 in pos from %scan above.
4)LENGTH TO REPLACE (not position of replace) 2999 
   The fourth parameter represents the number of characters in the source 
string to be replaced. If zero is specified, then the replacement string 
is inserted before the specified starting position. If the parameter is 
not specified, the number of characters replaced is the same as the length 
of the replacement string. The value must be greater than or equal to 
zero, and less than or equal to the current length of the source string. 
 I picked 2999 just in case there was a one letter command or program name 
being sent.
So after this you get 

CALL PGM(FORCASTX) in the cmd parm field used in callp to ExecuteCommand 

Now question now comes up because I go from 19 and replace 2999 from there 
what happens to the 17 of run over does it effect memory or create more 
"garbage" :) ??????

Lord knows I don't know... Any one else out there who does.

PS Good luck on new job you can see from writing skills and limited 
knowledge no way in heck I could do it.

Tare Care 
Bill Hopkins


d ExecuteCommand  PR                  ExtPgm('QCMDEXC') 
d  cmdstr                             Like(cmd) Const Options(*VarSize) 
d  cmdLen                       15P 5 Const 
d  cmdOpts                       3A   Const Options(*NOPASS)  
 
D cmd             S           3000A
> D pos             S              5U 0
>
> c     *entry        plist
> c                   parm                    cmd
> C                   Eval      pos = %scan('ENDCMD':cmd)
> C                   Eval      cmd = %replace(' ':cmd:pos:2999)
> C                   CallP     ExecuteCommand(cmd:%len(%trim
> C                             (cmd)))
> C                   eval      *inlr = *on
> C                   return
 





Scott Klement <klemscot@xxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
11/06/2003 06:12 PM
Please respond to RPG programming on the AS400 / iSeries

 
        To:     RPG programming on the AS400 / iSeries
<rpg400-l@xxxxxxxxxxxx>
        cc: 
        Subject:        RE: Junk Passed 32 on 3000A parm



Hi Bill,

This code won't actually solve the problem, at least not while you've
still got the %len(%trim(cmd)) in your code.   Sure, you now know where
the end of your string is, but you're not using that to set the length
that's passed to QCMDEXC. :)

The data that comes after "ENDCMD" is still going to be garbage, so unless
ENDCMD is always in positions 2995-3000 of the "cmd" string, your call to
%trim() will always face the chance of picking up "garbage."  (It's
actually not garbage, but rather it's memory that you aren't supposed to
be using)

A better solution (IMHO) than searching for some string would be creating
a *CMD as a front-end to your program.  Something like this should work:

          CMD        PROMPT('MY COMMAND')
          PARM       KWD(CMD) TYPE(*CHAR) LEN(3000) +
                       PROMPT('Command to run')

Now, the operating system knows that it needs to allocate 3000 chars to
use as the parameter, so you won't get the "garbage" that you were getting
before.

At any rate, this question has been asked and answered many times before.
Search the archives or the FAQ, and you'll find lots of ways to work
around the issue.

Good Luck


On Thu, 6 Nov 2003, Bill Hopkins wrote:
> D cmd             S           3000A
> D pos             S              5U 0
>
> c     *entry        plist
> c                   parm                    cmd
> C                   Eval      pos = %scan('ENDCMD':cmd)
> C                   Eval      cmd = %replace(' ':cmd:pos:2999)
> C                   CallP     ExecuteCommand(cmd:%len(%trim
> C                             (cmd)))
> C                   eval      *inlr = *on
> C                   return
_______________________________________________
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.



_______________________________________________
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-Ups:
Replies:

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.