Results 1 to 5 of 5

Thread: Find replace apostrophes - preferably free format

  1. #1
    Code400 Newbie
    Join Date
    Apr 2006
    Location
    East Coast, USA
    Posts
    10
    Rep Power
    0

    Find replace apostrophes - preferably free format

    Hello,

    I need to remove all occurrences of apostrophes within a text fields, I'd appreciate any help.

    I am importing data from a RPGLE environment to a VB.Net environment; I usually remove apostrophes after importing, however I have fields that are now part of the file key and therefore need to be cleaned up on the RPGLE level.

    (1) How would an apostrophes be identified in RPG, would I use a quotation within the apostrophes used as text identifiers to declare it?

    (2) How would I remove all the occurences of apostrophes within a text field?.... preferably using free format code?

    Thanks in anticipation. Once again, I appreciate any help.

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

  3. #2
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12605

    Re: Find replace apostrophes - preferably free format

    Take a look at %xlate


    http://www.code400.com/forum/showthr...light=%25xlate


    This code will convert all "!" to *Blanks in field cmdstring
    PHP Code:

        C                   
    eval      CmdString = %xlate('!' ' ' CmdString
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  4. #3
    Experienced Forum Member arrow483's Avatar
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    1,741
    Rep Power
    4218

    Re: Find replace apostrophes - preferably free format

    We call them single quotes. Generally in RPG a constant of a single quote is represented by two quotes. Thus

    CmdString = %xlate('''' : ' ' : CmdString)

  5. #4
    Analyst JonBoy's Avatar
    Join Date
    Jun 2005
    Location
    Mississauga, Ontario, Canada
    Posts
    392
    Rep Power
    1893

    Re: Find replace apostrophes - preferably free format

    Using %Xlate will only replace characters - i.e. substitute a space for a quote as in the examples above. You'll need a series of %check and %Subst if you simply need to remove the quote and replace it by nothingness.

    Code:
         d quotePosn       s              5u 0
         d text            s            200a
         d quote           c                   ''''
    
          /free
           quotePosn = %scan(quote: text );
           DoW quotePosn > 0;
             text = %subst(text: 1: quotePosn - 1 ) + %subst(text: quotePosn + 1 ); 
             quotePosn = %scan(quote: text );
           EndDo;

  6. #5
    Code400 Newbie
    Join Date
    Apr 2006
    Location
    East Coast, USA
    Posts
    10
    Rep Power
    0

    Re: Find replace apostrophes - preferably free format

    THANK YOU ALL! I progress only so far in my cut & paste RPG world, and when I have to do something outside it, I like to do it right; I really appreciate the timely replies, without the help my code would be the dreaded crap we all hate to work with! Thanks again.

  7. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Free Format Question
    By dcutaia in forum /Free format
    Replies: 9
    Last Post: January 17th, 2007, 09:26 AM
  2. Free Format RPG - Call program
    By dcutaia in forum /Free format
    Replies: 8
    Last Post: November 13th, 2006, 11:34 PM
  3. Move Char to numeric in free format RPG
    By ReachKrishna in forum /Free format
    Replies: 2
    Last Post: April 6th, 2006, 07:25 AM
  4. Found this hunk of find replace code
    By jamief in forum Tips for the Iseries/AS400
    Replies: 0
    Last Post: August 25th, 2005, 03:13 PM
  5. Free Format with SQLRPG
    By sam400 in forum RPG/RPGLE
    Replies: 7
    Last Post: February 1st, 2005, 08:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •