Results 1 to 18 of 18

Thread: Trim on RPGIII

  1. #1
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Trim on RPGIII

    Hi all,
    I can use only RPGIII and I want to do a trim. So %TRIM don't work on my system.
    How can i do that ?
    thank you

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

  3. #2
    Experienced Forum Member
    Join Date
    Feb 2009
    Location
    SE PA
    Posts
    94
    Rep Power
    1245

    Re: Trim on RPGIII

    In the distant past when I wrote RPG400 I would use a DO loop searching one character at a time from the end of the string until I found the last non blank character in the string. With that result in hand I would move the string to a result string utilizing SUBST.

    Which just goes to show you how much productivity goes down when your tool set is hampered.

    Steve

  4. #3
    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
    12606

    Re: Trim on RPGIII

    steve is correct... need to get the length of the field
    do a do loop substringing 1 char at a time!

    drop into an array find the first element that is non-blank
    reading from bottom to top!

    jamie
    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

  5. #4
    Lord of the Dance
    Join Date
    Aug 2008
    Location
    Memphis - Nashville TN
    Posts
    1,692
    Rep Power
    4710

    Re: Trim on RPGIII

    Quote Originally Posted by IroCorp View Post
    Hi all,
    I can use only RPGIII and I want to do a trim. So %TRIM don't work on my system.
    How can i do that ?
    thank you

    Use CvtRpgSrc command, then use the %trim bif.

  6. #5
    Moderator littlepd's Avatar
    Join Date
    Mar 2005
    Location
    Lewisville, TX
    Age
    50
    Posts
    1,111
    Rep Power
    3349

    Re: Trim on RPGIII

    For trailing blank characters, you can use the CHEKR op-code to find the position within the string of the last non-blank character. For leading blanks, a do loop reading each character in the string from the front is the only way I know.
    "Time passes, but sometimes it beats the <crap> out of you as it goes."

  7. #6
    Analyst
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    1,590
    Rep Power
    9580

    Re: Trim on RPGIII

    If embedded SQL is allowed, you may also use the SQL scalar functions TRIM, RTRIM and LTRIM in RPGIII:

    PHP Code:
    C/EXEC SQL  SET :MYRES TRIM(:MYVAR)
    C/END-EXEC 
    Birgitta

  8. #7
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Re: Trim on RPGIII

    Ok thank you.
    I can use embedded SQL and it's working

  9. #8
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Re: Trim on RPGIII

    Hi All,
    I "up" this topic because this time I can't use SQL.
    Do you know how to remove blank in a string ?
    Thank You

  10. #9
    Analyst DeadManWalks's Avatar
    Join Date
    Mar 2006
    Location
    Atlanta GA
    Posts
    1,587
    Rep Power
    3840

    Re: Trim on RPGIII

    Why are you forced to use RPG III, its only been out since the ice age.
    Hiking the APT in 2015.

  11. #10
    Programmer/Analyst I bryce4president's Avatar
    Join Date
    Apr 2007
    Location
    Lewisburg, PA
    Age
    31
    Posts
    2,895
    Rep Power
    4652

    Re: Trim on RPGIII

    Why are you forced to use RPG III, its only been out since the ice age.
    It just so happens that his company/boss was formed/born at the same time
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

  12. #11
    Sr. Product Specialist FaStOnE's Avatar
    Join Date
    Nov 2005
    Location
    Phoenix, AZ
    Age
    51
    Posts
    2,611
    Rep Power
    3993

    Re: Trim on RPGIII

    Try the XLATE command:

    Check here
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  13. #12
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,328
    Rep Power
    8646

    Re: Trim on RPGIII

    Quote Originally Posted by FaStOnE View Post
    Try the XLATE command:

    Check here
    yep...the good ol' days of RPG III (i really don't miss them that much lol)
    I'm not anti-social, I just don't like people -Tommy Holden

  14. #13
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Re: Trim on RPGIII

    OK thank you but maybe I have not explained properly my problem. Sorry

    The real thing I want to do is to transfert a String 8 char into a string 6 char.
    But the entry string can be " 123456 " so when I move it in the string 6 char, I might Have " 12345" or "23456 " (With MOVE or MOVEL)
    With a trim function, If I put the result in a String 6 char, I would have no problems, I would always have the 6 digit (in any case in other languages )

    Have you any idea how to do that ?
    Thank you

  15. #14
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,328
    Rep Power
    8646

    Re: Trim on RPGIII

    use SCAN, use arrays for each character, etc. there's several ways. the RPG reference manual is a good place to start...
    I'm not anti-social, I just don't like people -Tommy Holden

  16. #15
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Re: Trim on RPGIII

    OK So no function like trim ??

  17. #16
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,328
    Rep Power
    8646

    Re: Trim on RPGIII

    Quote Originally Posted by IroCorp View Post
    OK So no function like trim ??
    in RPG III absolutely not
    I'm not anti-social, I just don't like people -Tommy Holden

  18. #17
    Code400 Newbie
    Join Date
    Jul 2008
    Location
    France
    Posts
    12
    Rep Power
    0

    Re: Trim on RPGIII

    OK thank you
    That's why I never found anything.
    Come "reinvent the wheel" as we say in French

  19. #18
    Analyst JonBoy's Avatar
    Join Date
    Jun 2005
    Location
    Mississauga, Ontario, Canada
    Posts
    392
    Rep Power
    1894

    Re: Trim on RPGIII

    Quote Originally Posted by IroCorp View Post
    Ok thank you.
    I can use embedded SQL and it's working
    You can use embedded SQL but _not_ RPG IV - now that has to represent the most idiotic combination of rules I have ever had the misfortune to see.

    Jeez - is there no end to the madness!


    Jon P.

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

Facebook Comments


Similar Threads

  1. Is RPGIII inside RPGLE wrapper slower?
    By rpgKnight in forum RPG/RPGLE
    Replies: 2
    Last Post: December 22nd, 2008, 05:23 PM
  2. Problem with legacy RPGIII code
    By rpgKnight in forum RPG/RPGLE
    Replies: 5
    Last Post: October 3rd, 2008, 02:28 PM
  3. Store procedure keeping lock on PF
    By Devarshi in forum SQL
    Replies: 25
    Last Post: March 10th, 2007, 12:52 AM
  4. Converting S/36 RPGII to RPGIII or ILE
    By Red in forum RPG/RPGLE
    Replies: 6
    Last Post: July 14th, 2005, 09:18 AM
  5. Replies: 5
    Last Post: March 29th, 2005, 08:02 PM

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
  •