Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

TechTip: XLATE and Character String Manipulation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ukpi1b
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    According to IBM manuals the function of %xlate is to search the input string for any instances of the individual characters contained in the from string and to replace them with the corresponding character in the to string: Result=%xlate( from : to : input {: startpos} )

    For XLATE, characters in the source string (factor 2) are translated according to the From and To strings (both in factor 1) and put into a receiver field (result field).

    Original posting shows how to reformat source string via XLATE by specified syntax (changing FrFmt and ToFmt) instead of recommended by manual

    That is the main idea.
    Last edited by ukpi1b; 07-09-2011, 07:16 AM.

    Leave a comment:


  • david_l
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    The point of my putting in alpha characters in the SS# was just to show that the bif does work. It did not change in the original code because none of the characters in it were in either of the from or to strings.

    Leave a comment:


  • ukpi1b
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    Apparently this is not what original posting does.
    In first program FrSsn ='111-25-7890' which looks like Social Security Number, is reformatted to ‘9871-52-101’(ToSsa) by changing ToFmt value using the same characters as in FrFmt in different sequence. Then in it reformats it back to original. That’s all.

    To make this more fancy try special characters:
    FrFmt='@#^!()<{>]\'
    ToFmt=']>{!)(<@\#^'
    BTW. I have not seen SS# that contains letters

    Leave a comment:


  • david_l
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    Change your variable FRSSN to 'AAA-25-7890' and rerun it. After execution it should change to 'JJJ-25-7890'.

    Leave a comment:


  • ukpi1b
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    Thank you David.
    These are values in debug mode:

    Previous debug expressions
    > EVAL FrFmt
    FRFMT = 'ABCDEFGHIJK'
    > EVAL ToFmt
    TOFMT = 'JIHCDFEGAKB'
    > EVAL FrSsn
    FRSSN = '111-25-7890'
    > EVAL ToSsa
    TOSSA = '111-25-7890'
    I am not sure which values are missing

    Leave a comment:


  • david_l
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    The bif works the same. In your example, nothing changed because FrSsn did not have any of the values in either FrFmt or ToFmt. Change the first three characters in FrSsn to 'AAA', and they will change.

    Leave a comment:


  • ukpi1b
    replied
    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    %xlate BIF in free format does not work the same way.
    d FrFmt s 11A inz('ABCDEFGHIJK')
    d ToFmt s 11A
    d FrSsn s 11A inz('111-25-7890')
    d ToSsa s 11A
    /free
    ToFmt='JIHCDFEGAKB';
    ToSsa=%xlate(FrFmt:Tofmt:FrSsn);
    *Inlr=*on;
    /end-free
    After %xlate execution ToSsa gets FrSsn value '111-25-7890' . Tested on V5R4.
    I. Brender

    Leave a comment:


  • gman
    started a topic TechTip: XLATE and Character String Manipulation

    TechTip: XLATE and Character String Manipulation

    ** This thread discusses the article: TechTip: XLATE and Character String Manipulation **
    ** This thread discusses the Content article: TechTip: XLATE and Character String Manipulation **
    FYI: This can also be done in free-format with the %XLATE Built-in Function...

    From the RPG IV Reference manual: %XLATE(from:to:string{:startpos})
Working...
X