Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

LENGTH and LENGTH OF in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 5:09 pm    Post subject: LENGTH and LENGTH OF in cobol
Reply with quote

what is the difference between LENGTH and LENGTH OF in cobol?
Back to top
View user's profile Send private message

gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Thu May 25, 2006 5:14 pm    Post subject:
Reply with quote

Crudely classifying these two,
"Length" is a intrinsic function operated of variables
"Length OF" is a special register

Coding either Function Length(variable_name) or LENGTH OF Variable-Name would return the same result? the length of variable-Name in bytes.
Whereas the LENGTH function can only be used where arithmetic expressions are allowed, the LENGTH OF special register can be used in a greater variety of contexts.
For example, the LENGTH OF special register can be used as an argument
to an intrinsic function that allows integer arguments. (An intrinsic function cannot be used as an operand to the LENGTH OF special register.) The LENGTH OF special register can also be used as a parameter in a CALL statement.
Back to top
View user's profile Send private message
abhishekraghav

New User


Joined: 31 Mar 2006
Posts: 9
Location: Pune

PostPosted: Thu May 25, 2006 5:29 pm    Post subject:
Reply with quote

The LENGTH is a function that returns an integer equal to the length of the argument in bytes. The function type is integer. and it returns a 9 bytes integer.

While LENGTH OF is an special register, 4 bytes in size i dont know the exactly purpose of this register. may be it is used to store length of variables.

If any one knows purpose of the LENGTH OF then please write.
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 5:58 pm    Post subject:
Reply with quote

i also believe that LENGTH should the number of characters in the argument, but this is not the case. this also includes the filler thus varying the size of the argument,

okay,
go for the example.

WS-STRING PIC X(20).
WS-COUNT PIC X(4)

MOVE 'ABCD' TO WS-STRING
MOVE FUNCTION LENGTH (WS-STRING) TO WS-COUNT

what will be the value of ws-count.
i know u may say it 4, but the result is other than 4.

any suggestions...........?
Back to top
View user's profile Send private message
manisha-s
Warnings : 1

New User


Joined: 22 May 2006
Posts: 13

PostPosted: Wed May 31, 2006 4:16 pm    Post subject: Re: LENGTH and LENGTH OF in cobol
Reply with quote

if code is like this


ws-string pic x(20).
ws-count pic 99.

move 'abcd' to ws-string.
move length(ws-string) to ws-count.
display ws-count

result:
20
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us