You must have some non-English alphabets in your toto.txt file... because the original ESC.txt file you gave didn't have any of those and does work. So, I'm guessing it's about having non-UTF8 characters in your input file, but you're running Hollywood in UTF8 mode (the default nowadays).
You could run your whole Hollywood app in non-UTF8 mode (
SetDefaultEncoding() or
@OPTIONS), or define the character encoding in functions when needed (read more about
encodings).
This would probably work when just defining the encoding in a function:
Code: Select all
text$ = FileToString("ram:toto.txt")
pos$ = FindStr(text$, Chr(27), True, 0, #ENCODING_RAW)
consoleprint(pos$)
BTW. if you want to get rid of the whole escape sequence (Amiga escape sequences explained
here), you could use, for example,
PatternReplaceStr() like this:
Code: Select all
text$ = FileToString("ram:toto.txt")
s$ = PatternReplaceStr(text$, "\27%[%d*%a", "")
StringToFile(s$, "ram:toto2.txt")
To explain the pattern:
"\27" is the code point value for the escape character
"%[" matches the "[" character
"%d*" matches 0 or more occurences of digits, d tells it's a digit and * tells the amount of them
"%a" matches any single letter
So, if there's a character combination matching all these rules, it will be removed. In this way you get rid of start and end markers for escape sequences in one go.