Page 1 of 1

What is the difference between INSPECT and FUNCTION LENGTH?

Posted: Fri Nov 14, 2014 12:03 pm
by Abhilash Sharma
Hi,

I want to find length of a field. Once I know that I'll pad zeroes. But I am not sure if I should this using INSPECT or with intrinsic FUNCTION LENGTH. What is the difference between the two approaches, I'm confused?

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Fri Nov 14, 2014 5:36 pm
by Robert Sample
If your variable is in WORKING-STORAGE, the length does not change, ever. So FUNCTION LENGTH will only return one value no matter what data is stored in the variable. INSPECT allows you to locate the last byte of relevant data in the variable.

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Fri Nov 14, 2014 5:48 pm
by William Collins
Can you show an example of what you are trying to do?

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Mon Dec 01, 2014 5:10 pm
by Abhilash Sharma
I've a field which migh tcome like this "$$$$$1234" or "$$$$$$234" or "$$$$$$$34" or "$$$$$$$$4" or "$$$$$$$$$", where $ represents a space and it might alos be like "1234$$$$$" etc. I need to replace $ with a zero.

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Tue Dec 02, 2014 4:13 am
by Robert Sample
Use INSPECT or reference modification.

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Tue Dec 02, 2014 4:21 pm
by zprogrammer
Are you sure "1234$$$$$" replacing $ with 0 for this type is correct?
Don't you need any justification?

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Thu Dec 04, 2014 2:09 pm
by Abhilash Sharma
I'd need justifcation too. I'll try with INSPECT and reference modification.

Re: What is the difference between INSPECT and FUNCTION LENG

Posted: Thu Dec 04, 2014 3:55 pm
by zprogrammer
Try FUNCTION NUMVAL