Looking for chr(13) with INDEX function?

freak

Member
=index(somestring,chr(13)) always returns 0 even when I know that chr(13) is there. Is there some way around this?
 
This works.

DEF VAR X AS CHAR.
X = 'abc' + CHR(13) + 'def'.
DISPLAY LENGTH(X) INDEX(X,CHR(13)).

The result is 7 and 4
 
My guess is that you are seeing a newline in your output and assuming that it is chr(13). They are only the same under certain circumstances.
 
This is a file that I'm reading into a variable. I've looked at the file with a hex editor and the 0D's are in it. Can the chr(13)'s get lost when I read the file into variable?
 
Maybe try the ASC function on the newline character in your string to find out what the ASCII value became.

What OS? Perhaps Progress is performing a conversion.

What method are you using to read the string? I didn't realise there was a method to read multiple lines into one string variable.
 
Yes I am. That's what I started to guess what was happening last night. I couldn't test it till this morning though. Thanks for confirming. Is there a way to read the file exactly as it is on disk into a variable?
 
Use no-convert in your input stream from file.

READKEY STREAM InputStream.
IF LASTKEY<0 THEN oStr=?.
else inputstr = input + chr(lastkey).
 
Thanks you! I actually just tacked on a chr(13) to the import statement and that is working. It was a quick fix.
 
That's why it's a good idea to mention the Progress/OpenEdge version you are using. I've seen posts in this forum concerning version as old as V7 (AFAIK beginning of the 1990s) ...

Best regards, RealHeavyDude.
 
Yeah.

Tom is notorious for that - but, as far as I can see, his intentions are well meant, and, last but not least, I do agree with him.

Regards, RealHeavyDude.
 
I don't actually throw things... at worst I might insist that you buy the beer should we ever have the opportunity to meet ;)
 
Crikey there's an incentive to upgrade if ever I heard one!

<upgrades> <hides wallet> ;)
 
Back
Top