Page 1 of 1

How do u Calculate the total no of chars in string

PostPosted: Mon Dec 13, 2010 12:02 pm
by ragur.satheesh
How do u calculate the total no of characters in string

Re: How do u Calculate the total no of chars in string

PostPosted: Mon Dec 13, 2010 2:07 pm
by sriraj1122
You can use INSPECT to count the characters in a variable.

Re: How do u Calculate the total no of chars in string

PostPosted: Mon Dec 13, 2010 5:10 pm
by Robert Sample
COBOL does not have "strings" in the sense other languages have strings (where the length can vary while the program is running). COBOL WORKING-STORAGE variables, whether numeric, alphabetic, or alphanumeric, are fixed length and that length is fixed at compile time. There are ways to simulate strings in COBOL but such techniques require some advanced knowledge of COBOL.

Re: How do u Calculate the total no of chars in string

PostPosted: Wed Dec 15, 2010 4:10 pm
by Srikk

Re: How do u Calculate the total no of chars in string

PostPosted: Wed Dec 29, 2010 12:21 pm
by FUFENG
there is a indirect way to solve this problem

specify the string is test-string

example:

UNSTRING TEST-string
DELIMITED BY
INTO COUNT1 COUNT IN LEN
DELIMITER IN STD.

Re: How do u Calculate the total no of chars in string

PostPosted: Sun Jan 02, 2011 1:08 pm
by FUFENG
NOW,I FIND THE WAY TO SOLVE THIS QUESTION
EXAMPLE
MOVE LENGTH OF STRING1 TO A

IT'S USE LENGTH OF TO CALCULATE THE TOTAL NO OF CHANRS IN STRING

Re: How do u Calculate the total no of chars in string

PostPosted: Sun Jan 02, 2011 1:22 pm
by FUFENG
OTHER
INSPECT STRING1 TALLYING FOR CHARACTERS BEFORE L

YOU CAN USE THIS TO CALCULATE THE TOTAL NO OF CHARS

Re: How do u Calculate the total no of chars in string

PostPosted: Mon Jan 03, 2011 10:28 am
by dick scherrer
Hello,

Neither of your "solutions" is completely true/useful. . .

Both will execute, but the results will most likely be different. . .

Also, turn off your CAPS LOCK. . .

Re: How do u Calculate the total no of chars in string

PostPosted: Wed Jan 05, 2011 11:58 am
by Schubie
1) What is the "delimiter'"? For the sake of discussion, let's assume it to be a space. 2) What defines "characters in a string"? If the "string" is a name like "George Washington", the lenght of the "string" is 17 characters. This could be determined by redefining the variable as a table and count from the end until the first non-space character is reached. If we count from the left until the first delimiter (aka space) is reached, the routine would only count 6 characters. If we simply count non-space characters, the result would be 16. These are not COBOL issues, I'd ask the same for any programming language.