ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Edit word needed

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

  • Edit word needed

    In my program, there is a 6 digit numeric field that I want to display with an edit word. when the filed contains 081450, I want it to display as 08.14.50. What %editw bif would do that

  • #2
    Zero blank blank dot blank blank dot blank blank

    Code:
    dcl-s FromDate      zoned(6)    inz(081450);
    dcl-s ToDate        char(8);
    
    ToDate = %subst(%editw(FromDate:'0  .  .  '):2);

    Comment


    • #3
      I'm just curious why it can't be done with just an edit word without having to sub-string it out. That's the problem I was having, i.e., getting the editw to do the job by itself

      Comment


      • #4
        It's an idiosyncrasy of edit words, Greg. Edit words suppress leading zeros by default. To turn off zero suppression, you begin the edit word with a zero. However, this adds one byte to the result. The substring throws away the unneeded first byte.

        Comment


        • #5
          Originally posted by TedHolt View Post
          It's an idiosyncrasy of edit words, Greg. Edit words suppress leading zeros by default. To turn off zero suppression, you begin the edit word with a zero. However, this adds one byte to the result. The substring throws away the unneeded first byte.
          Yeah, the editw was kinda quirky. I was beating my head against the wall. Thanks for the help

          Comment


          • #6
            Just in case you were discussing date data types, this would probably be a more elegant solution:

            Code:
            dcl-s mdyDate date(*mdy.);      // the . at the end of the date format is the seperator
            dcl-s charDate char(8);         
            
            mdydate = %date();             
            charDate = %char(mdyDate);     
            
            *inlr = *on;                   
            return;
            If this does not apply to you, then it's possible someone else may stumble on this thread looking for ways to handle non-standard date separators.


            Comment


            • #7
              You can use the edit word without a substring function if you use an EVALR op code.

              Code:
              EvalR ToDate = %editw(FromDate:'0  .  .  ');

              Comment


              • #8
                As with all things - there is more than one way to skin the proverbial cat...

                Code:
                dcl-s fromdate zoned(6) inz(081450); 
                dcl-s Todate  Char(8);               
                dcl-s Datewrk Date;                  
                
                Datewrk = %Date(FromDate:*MDY);      
                ToDate = %Char(DateWrk:*MDY.);
                Todate will have 08.14.50.

                Comment

                Working...
                X