Good afternoon, please have a string type variable and it has a text of x characters, there is a function so that I can get the exact size of this content, I am joining 3 variables in a string and getting whitespace between them , example: set variable to var1 & var2 & var3 So, what for? text1 text2 text3 and I need you to stay
It's not clear to me from the question how var1 etc. are defined. Is it something like:
01 var1 string. *> var1 is a string object
...or more like:
01 var pic x(32). *> var1 is a conventional COBOL alphanumeric data item.
If the first, you could try using the Trim function, e.g.
set variable to var1::Trim & space & var2::Trim & space & var3::Trim.
You can create a user function that computes the trailing space trimmed length of a PIC x(length) data item and then use the trimmed length in reference modification such as stringvar(1: trimmedlength) to reference the trailing space trimmed string.
Here's a possible example of such a trimmed length user function:
01 trim-length pic 9(9) binary.
01 string1 pic x any length.
01 length1 pic 9(9) binary.
procedure division using string1 returning length1.
move 0 to trim-length
inspect function reverse(string1)
tallying trim-length for leading spaces
* inspect string1 tallying trim-length for trailing spaces
compute length1 = length of string1 - trim-length