Kbase 19519: Editor:CURSOR-OFFSET attribute doesn't match SUBSTRING func.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  27/01/2005 |
|
Status: Unverified
FACT(s) (Environment):
Windows 32 Intel
SYMPTOM(s):
Modifying the Progress Editor Widget Functionality
CURSOR-OFFSET returning incorrect data.
SUBSTRING returning incorrect string.
CAUSE:
The editor widget contains two characters at the end of each line. They are CHR(13) and CHR(10). This is the standard end-of-line marker on Windows. The editor converts text which contains only CHR(10) to both CHR(13) and CHR(10). But SCREEN-VALUE removes the CHR(13) when the value goes back to a variable. This is the reason why CURSOR-OFFSET and SUBSTRING do not match in Windows environments.
DEFINE VARIABLE a AS CHARACTER VIEW-AS EDITOR SIZE 10 BY 5.
a = "123" + CHR(10) + "456" + CHR(10) + "789".
DISPLAY a.
a:CURSOR-OFFSET = 6.
ENABLE a.
DISPLAY SUBSTRING(a,6,1).
WAIT-FOR GO OF a.
When you run it, CURSOR-OFFSET is pointing to "4", but SUBSTRING to "5".
FIX:
The correct way to program the above code is adding the CHR(13) along with the CHR(10):
DEFINE VARIABLE a AS CHARACTER VIEW-AS EDITOR SIZE 10 BY 5.
a = "123" + CHR(13) + CHR(10) + "456" + CHR(13) + CHR(10) + "789".
DISPLAY a.
a:CURSOR-OFFSET = 6.
ENABLE a.
DISPLAY SUBSTRING(a,6,1).
WAIT-FOR GO OF a.
Now both methods point to "4"