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



Oops, my example was poor and should not have had the outer (initial)
Enquote(). But the point is valid and the result would be as expected.
This one would work with QCMDEXC:

MY_COMMAND = 'MYEMAIL TO(' + Enquote(recipient) + ') '
+ 'FROM(' + Enquote(sender) + ') '
+ 'SUBJECT(' + Enquote(subject) + ') '
+ 'BODY(' + Enquote(body) + ')'
;
QCMDEXC(MY_COMMAND: %Len(MY_COMMAND)) ;


Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"If we were logical, the future would be bleak indeed. But we are more than
logical. We are human beings, and we have faith, and we have hope, and we
can work."
-- Jacques Cousteau


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) + ')'
)
QCMDEXC(MY_COMMAND: %Len(MY_COMMAND)) ;

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
http://www.linkedin.com/in/dennislovelady
--
"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
emailed.
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
EMAIL.
Cause . . . . . : An expression operator was found immediately
before
or
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
the
CHGVAR and IF commands. Recovery . . . : Remove the expression
operator
or insert a blank between the operator and the character string.
More
information on expression operators can be found in the CL
Reference manual."


Is there an easy way to edit the CMD parameters as part of the CMD?
Or
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
documents.

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

Thanks
---Dale
--
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 http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.