Page 1 of 1

Is ReplaceStr() limited to 20 replacements?

Posted: Sat Jun 12, 2010 4:12 pm
by TheMartian
Hi

Is there a limitation built into the ReplaceStr() function? If I replace characters at more than 20 locations in a string I get an error. The example below works and will read a single string to a file with newline characters between each number in raw format. Then, if I read from the file using ReadLine(), I get 21 lines of data back. But if I add ";21" to the string and thus has 21 ";" chars to replace with "\n" the ReplaceStr() function fails. As you can see from the code this was tested on the windows version of Hollywood.

txt$="start;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20"
txt$=ReplaceStr(txt$, ";", "\n")

OpenFile(2, "C:\\temp\\mintekst", #MODE_WRITE)
WriteString(2, txt$)
CloseFile(2)

OpenFile(1, "C:\\temp\\mintekst",#MODE_READ)
While Not Eof(1) Do NPrint(ReadLine(1))
CloseFile(1)

WaitLeftMouse


regards
jesper

Re: Is ReplaceStr() limited to 20 replacements?

Posted: Mon Jun 14, 2010 12:59 pm
by airsoftsoftwair
This is a bug in Hollywood which was already discovered earlier by Paul Bloedel. It will work correctly in the next version :)

Re: Is ReplaceStr() limited to 20 replacements?

Posted: Mon Jun 14, 2010 7:43 pm
by TheMartian
Hi

Ok. Sounds good. I was thinking of using it to build strings making up a complete data block for small databases and save it with 'inbuilt' newline characters as terminators instead of doing multiple writes in a loop. The reverse process would then be either reading data using ReadLine() or read in the entire block and splitting it as discussed in another subject on these pages.

regards
Jesper