Unicode string length

Hi,

please I need to get length of unicode string. I am trying to do this:

IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
INPUT-OUTPUT SECTION.

working-storage section.
01 w-text pic n(10).
01 w-x pic 999.

PROCEDURE DIVISION.
********************
000000-CONTROL SECTION.
move n"abcd" to w-text
display w-text(1:1)
display function length(w-text)
perform varying w-x from function length(w-text) by -1
until w-x < 1 or w-text(w-x:1) <> nx"0020"
end-perform
display w-x
exit program
.

I want return number 4 in this example. But in perform I still get access memory violation error. When I try command display w-text(1:1) I got result 'ab'. Is this problem? So when I do w-text(10:1) in first perform loop, I got out of my memory?

Please how to correctly solve this?

Parents Reply Children
No Data