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



That got me thinking about the UNIXCMD library. How about this?

RPGLE:
Dcl-f UNIX disk(1024) handler('UNIXCMD/UNIXCMDOA' :UnixCmd) usrOpn ;

Dcl-s UnixCmd char(1024) ;
Dcl-ds StdOut len(1024) End-ds ;

Dcl-s Display char(52) ;

//----------------------------------------------------------------------

UnixCmd = '/QOpenSys/pkgs/bin/python3 src/Python3/misc/proper_case.py "GEORGE" "WASHINGTON"';

sysCmd('ADDLIBLE UNIXCMD *LAST');
Open UNIX;
Read UNIX StdOut;
Dow not %eof(UNIX);
Read UNIX StdOut;
Enddo;
Close UNIX;
sysCmd('RMVLIBLE UNIXCMD');
Display = StdOut;
Dsply Display;

*inLR = *on;
Return;

Python:
import sys

parms = sys.argv
parms.pop(0)

return_value = ""
try:
for parm in parms:
return_value += parm.capitalize() + " "
except:
return_value = "Error"

print(return_value.rstrip())




-----Original Message-----
From: Buck Calabro [mailto:kc2hiz@xxxxxxxxx]
Sent: Monday, January 14, 2019 4:12 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Need help to convert a name in upper case, to mixed case

On 1/14/2019 4:46 PM, Jack Woehr wrote:
On Mon, Jan 14, 2019 at 2:36 PM Tyler, Matt
<matt.tyler@xxxxxxxxxxxxxx>
wrote:

Plus, the tool I sent gives me the ability to wrap it in an external
SQL procedure. How would Python accomplish this?


If you can call a CL passing parameters, you can call Python with
those params, because you can call Python from a CL.

A little while ago, I had to plug in a Python function/process into an existing RPG program. I'm on 7.3, and to the best of my knowledge, Python is not a participant in the CALL/PARM family. That is, if my RPG program were to call a CL which were to invoke a Python program, and the Python program were to want to return a mixed case name back to the caller, there's no mechanism to pass it back in the parameter list.

I solved it thanks to Scott Klement's insights into how pipes work between PASE and ILE. Basically, my RPG program sets up pipes for the 3 'standard' streams, does a spawn() that invokes the Python program with UPPER_NAME_PARM and then Python does its thing, putting lower_name_parm on STDOUT, which the RPG program then does an fdopen() and fgets() to retrieve. Don't forget to translate from ASCII :-)

If there's a simpler way that a CLP can get an answer back from a Python program, I'm all ears!

--
--buck

http://wiki.midrange.com
Your updates make it better!



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.