Left / Right Trim in IBM COBOL 
Author Message
 Left / Right Trim in IBM COBOL

Is there a way using IBM COBOL for OS390 to do
right or left trim, I mean remove leading or trailing blanks?

TIA
Max



Tue, 09 Mar 2004 15:01:40 GMT  
 Left / Right Trim in IBM COBOL
Hi Max,
        you have to write the 'left trim' function yourself. Something like

        move spaces to OUTPUT-FIELD

        for i = 1 to xx
                if INPUT-FIELD(i:1) <> SPACES
                        OUT_INDEX = OUT-INDEX + 1
                        OUTPUT-FIELD(OUT-INDEX:1) = INPUT-FIELD(i : 1)
                end if
        end loop

        Or whatever the equivalent COBOL is, it's been a few years since I
wrote any.

        Not sure if a RIGHT-TRIM is of any use, as when moving a short-field to
a longer field, the receiving field will be padded with ZERO's.
Alternatively, if you're trying to remove trailing spaces from a
variable length record before it's written; something like

        for i = max-output record length by -1 until 1 < 2
        or my-flag = 'non space character found'
                if my_record(i:1) <> SPACE
                        set record length to i
                        set my-flag to whatever...
        end loop

Bill

(I'm sure someone else will give you the proper COBOL syntax, control
statement names etc)    

Quote:

> Is there a way using IBM COBOL for OS390 to do
> right or left trim, I mean remove leading or trailing blanks?

> TIA
> Max



Tue, 09 Mar 2004 19:16:26 GMT  
 Left / Right Trim in IBM COBOL
Check the COBOL FAQ - there are several examples for you there.

--
Bill Klein
 wmklein <at> ix.netcom.com

Quote:
> Is there a way using IBM COBOL for OS390 to do
> right or left trim, I mean remove leading or trailing blanks?

> TIA
> Max



Tue, 09 Mar 2004 19:18:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Right, left, Right.

2. Right Trim

3. Right to left question

4. Right to left cursor utility

5. Hebrew and Right-to-Left

6. left mouse button = right mouse button

7. How to make a check right before leaving a program

8. Relational Trees - ? Scroll Left to Right

9. bold, italic, underline and right & left alignment

10. Hove to shift page numbers from left to right side depending on even uneven pagenumber

11. LEFT AND RIGHT ARROWS TO CHANGE SORT ORDER

12. Have a Get as a calculator (right to left)

 

 
Powered by phpBB® Forum Software