Strangeness with strings

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Strangeness with strings

Post by pjj »

1) I noticed index in strings starts with 1, and not 0 (as usual). Not sure if this is by design or not, I guess it'd be more convenient to start it from 0, but hey, I can live with that.

2) I used Document.Text to get content of a file, e.g.:

Code: Select all

if (MainApp.OpenFile("sessions.csv"))
{
  sStr = trim(Document.Text);
  TRJDocument.Close;
  MainApp.DocumentIndex = currentDoc;
}
Strangely enough, length(sStr) holds not the actual number of bytes but bigger: number of bytes plus two times "number of lines minus 1". In other words a string, to which file with this content:
aaa
bbb
zxc
would be read thru Document.Text, would have length of 13 (without trim it'd be 15), and not 11. Newline format in the file is Unix, but it is read as if it was Windows. Size of a file is 11 bytes. Now, this too may be by design :o but anyway I hope my report will save you some some hair pulling.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Post Reply