ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

%trim used as a replace

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

  • %trim used as a replace

    Code:
      //-------------------------------------------------------------//
          //   Thanks again to the founding father of cool Sh|t on the   //
          //   iseries - Scott Klement                                   //
          //-------------------------------------------------------------//
         d String1         s             20a
         d String2         s             20a
         d String3         s             20a   inz('PRO#: 9999999')
         d String4         s             20a
    
          /free
    
              String1 = *all'$';
              %subst(string1:9:3) = 'TXT';
              // String1 =  '$$$$$$$$TXT$$$$$$$$$'
    
              String2 = %triml(String1:'$');
              // String2 is now 'TXT$$$$$$$$$'
    
              String2 = %trim(String1:'$');
              // String2 is now 'TXT'
    
              // in the below case you have a text field that
              // contains free form data.  You have been assigned
              // the task of pulling the order # (pro#) from this
              // text and chaining to a file with it.
              // Sure you could use %scan or %replace...but
              // your IT manager hates those bifs and they
              // have been outlawed from your system.
              // so we must use %trim
    
              String4 = %trim(String3:'PRO#: ');
              // String4 is now '9999999;
    
    
             *inlr = *on;
    
          /end-free
    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
Working...
X