|
Looks like you got the first 2 XLATE parms flipped. The 1st is the receiver and the 2nd is source Try: XLATE NEWSTR, PARM-STRING, PARM-OLDCH, PARM-NEWCH; ----- Original Message ----- From: "Winchester Terry" > As the subject implies, I'm an MI newbie and having a > problem using the XLATE instruction. My goal is pretty > simple - create a program that accepts 3 parameters > > Parm1= String 10 chars > Parm2= OldChar 1 char > Parm3= NewChar 1 char > > and translate each character in "string" from OldChar > to NewChar. At least I *thought* this was simple :( > My ultimate goal is to handle a string of 2000-3000 > characters callable from any HLL. > > Here is my code, but it does not seem to translate > the characters properly. The SHOWMSG routine is > straight from Leif's MI examples. > > DCL SPCPTR .P1 PARM; > DCL DD PARM-STRING CHAR(10) BAS(.P1); > > DCL SPCPTR .P2 PARM; > DCL DD PARM-OLDCH CHAR(1) BAS(.P2); > > DCL SPCPTR .P3 PARM; > DCL DD PARM-NEWCH CHAR(1) BAS(.P3); > > DCL OL PARMS(.P1, .P2, .P3) EXT PARM MIN(3); > > DCL SPCPTR .NEWSTR INIT(NEWSTR); > DCL DD NEWSTR CHAR(10); > > ENTRY * (PARMS) EXT; > CPYBLA NEWSTR, PARM-STRING; > CPYBREP PARM-STRING, " "; > XLATE PARM-STRING, NEWSTR, PARM-OLDCH, PARM-NEWCH; > CPYBLA PARM-STRING, NEWSTR; > > CAT MSG-TEXT, PARM-STRING, "|"; > CALLI SHOW-MESSAGE, *, .SHOW-MESSAGE; > RTX *; > %INCLUDE SHOWMSG > > When I call this program from a command line: > > CALL PGM(MYPGM) PARM('1234567890' '4' 'A') > > I see the results in my message queue but > nothing has changed: > > >From . . . : TWINCHES 08/31/04 09:47:43 > 1234567890| > > Of course, I was expecting to see: 123A567890| > > Originally, the XLATE code looked like this: > > XLATE PARM-STRING, PARM-STRING, PARM-OLDCH, PARM-NEWCH; > > but since *that* didn't work I assumed that separate string > variables were needed, hence my new version above that uses > NEWSTR as a temporary variable to hold the inbound string > parameter. > > I'm missing something simple here...but just can't see it... > Any help would be appreciated :) > > Terry
As an Amazon Associate we earn from qualifying purchases.
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.