> ReadLine() works with lines previously created by WriteLine().
> But what I would like to accomplish is to be able to edit a text file outside of AppGameKit app and then read the data back into AppGameKit app.
> If we, for example, take a *.txt file created with notepad with a single word in it (let it be "Hello"), then read it with ReadLine() we will get some nonsense instead of that word.
> I guess, that is because AppGameKit writes to files in binnary or in hexadecimal or in some other inhumane format. Hopefully there is any way / tool to convert to/from that format.
---
WriteLine() will write out text in human readable format. Likewise, ReadLine() will read a line of (human readable) text that is terminated by a new line. So if you have a file with just a single word for instance, you must have a new line after it. Similarily, if having multiple lines of text, the last line need be empty.
In other languages you often just import an entire file into a byte-buffer, and then convert that to a string. Not so in AGK. Those newlines are muy importante!
Here's a simple example of reading a string from file:
function importConnectID()
cf as string
out as string
cf = "connectID.txt"
if GetFileExists(cf)
OpenToRead(1, cf)
out = readLine(1)
CloseFile(1)
else
out = "ERROR"
endif
endFunction out
(I don't believe in using $ or # to signify variable type, so I declare them explicitly and without any silly special characters. I do believe in Error handling though...
)