Hi, Dale:

I used to fight to get apostrophes just right within RPG --- and then
"quoted" parameters within a quoted command add to the complexity --- but I
don't fight that anymore. Instead, I have written a procedure (Enquote)
that's in my most frequently-used service program to do all the work for me.

So now, let's say I need to build a "MYEMAIL" command, which takes the
following simple parameters:

TO - the recipient address
FROM - the sender address
SUBJECT - guess
BODY - guess again

And the kicker would be that I need to put it into a variable that's ready
for QCMDEXC (not QCMDEXE, whatever that is ;) ).

Now it is a simple matter:

MY_COMMAND = Enquote('MYEMAIL TO(' + Enquote(recipient) + ') '
+ 'FROM(' + Enquote(sender) + ') '
+ 'SUBJECT(' + Enquote(subject) + ') '
+ 'BODY(' + Enquote(body) + ')'

Voila! Problem solved! (Of course, you have to ensure that MY_COMMAND is
long enough to hold the result, and all that jazz. . . and to understand
that there's a hard limit of 32K bytes in any result (which you could easily
bump to 64K).

Code is at http://code.midrange.com/aac45831b0.html

I actually favor a later version I have of this - more c-like, with length
checks and the like, but this one reads so much more clearly.

Dennis Lovelady
"To cease smoking is the easiest thing I ever did. I ought to know because
I've done it a thousand times."
-- Mark Twain

I have somewhat convoluted series of programs that is used to email
shipping documents and invoices to customers. Our billing process runs
a CL program that (naturally) calls RPG. In the RPG program I use
QCMDEXE to put together a long string of 7 parameters to call another
CL program which uses software called BLUESERIES to actually do the
emailing (and occasional fax).

As I struggled to put this together, I had trouble getting RPG to
string the commands together with quotes and parentheses, etc. I don't
remember all the methods I tried.

I created a command to call the last CL program. RPG calls the CMD
with parameters, which runs the CL program and the documents get
Customers are happy, billing dept is happy, life is good.

Then one of our customers has an email address with a hyphen in it.
The CMD blows up.

"Message . . . . : Expression operator not allowed for parameter
Cause . . . . . : An expression operator was found immediately before
after a character string with no intervening blanks on a parameter
that does
not support expressions. Character string expressions are only
allowed in
CHGVAR commands, IF commands, or a parameter defined with EXPR(*YES).
Arithmetic, relational, and logical expressions are only allowed on
CHGVAR and IF commands. Recovery . . . : Remove the expression
or insert a blank between the operator and the character string.
information on expression operators can be found in the CL Reference

Is there an easy way to edit the CMD parameters as part of the CMD?
if I edit in RPG and find a hyphen, what can I do to pass it correctly?

This whole thing took me a while to get working and for some reason, I
could not set up the QCMDEXE call correctly with the 7 parameters if I
had to "CALL MYCLPGM (parm1 parm2 parm etc). But I could with the CMD.

So to recap in reverse, the final step is a CL program that receives
parameter of email address, customer name, type of document to send.
It creates a path statement and runs BLUESERIES to send/fax the

A CMD is used to fire off the CL program. If the email address has a
hyphen in it, the CMD bombs.

An RPG program calls the CMD

This is the RPG programming on the IBM i / System i (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

This thread ...


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

This mailing list archive is Copyright 1997-2020 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].