Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding field lengths 2

Status
Not open for further replies.

sp1502

Programmer
Dec 15, 2000
15
US
Is there any way to find different fields length of input records?
Ex.
7654321 would like to know it is 7 numeric character long
234 " " 3 "

Thx
 
Hi,

If you are working with CSV files, with comma's, etc., you can just interpret them, counting charactes and moving them into some fields.

Regards,

Crox
 
Hi SP,

The compiler I use has a feature that allows you to reference the length of a field directly, i.e.:

Code:
      move length of ws-7-byte-fld to ws-len-7

Your's might too. Remember though, that a pic 9(7) comp-3 field will result in ws-len-7 = 4 bytes.

If you are really looking for the SIGNIFICANT digits of the field, i.e. ws-7-byte-fld contains 0000123 and you want to determine the length of 123, use this:

Code:
        move as above
        move zeros to ws-zero-cnt
        inspect ws-7-byte-fld tallying ws-zero-cnt for
                leading zeros
        compute ws-sig-digits = ws-len-7 - ws-zero-cnt

If your compiler doesn't support "length of" you can use "inspect" (or similar feature) tallying characters to get the field length.

Good luck. Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top