New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Commodore
Commodore
1086 views

Unicode string length

Jump to solution

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?

Tags (3)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Commodore
Commodore

Sorry my bad, I forgot to put directive

C     $SET DIRECTIVES (SBODBC.DIR) NSYMBOL"NATIONAL"

View solution in original post

0 Likes
1 Reply
Highlighted
Commodore
Commodore

Sorry my bad, I forgot to put directive

C     $SET DIRECTIVES (SBODBC.DIR) NSYMBOL"NATIONAL"

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.