How read the text lines from txt file?

Find quick help here to get you started with Hollywood
Post Reply
User avatar
Juan Carlos
Posts: 933
Joined: Mon Sep 06, 2010 1:02 pm

How read the text lines from txt file?

Post by Juan Carlos »

I have this little question but a big problem for me, How read text lines from txt file? I open the file and insert as items every text line?
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

Re: How read the text lines from txt file?

Post by PEB »

Well, you could use ReadLine().
You could also process your text file using FileToString() and then SplitStr() with "\n" as your token$.
User avatar
Juan Carlos
Posts: 933
Joined: Mon Sep 06, 2010 1:02 pm

Re: How read the text lines from txt file?

Post by Juan Carlos »

Any easy and single example to open the txt file?
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

Re: How read the text lines from txt file?

Post by PEB »

The Hollywood documentation has a lot of good example code, such as this:

Code: Select all

OpenFile(1, "S:Startup-Sequence")
While Not Eof(1) Do NPrint(ReadLine(1))
CloseFile(1)
User avatar
Juan Carlos
Posts: 933
Joined: Mon Sep 06, 2010 1:02 pm

Re: How read the text lines from txt file?

Post by Juan Carlos »

PEB wrote:The Hollywood documentation has a lot of good example code, such as this:

Code: Select all

OpenFile(1, "S:Startup-Sequence")
While Not Eof(1) Do NPrint(ReadLine(1))
CloseFile(1)
Thanks although I want read every line and put inside of variable to use every line of text, and I don't know as to do this, read the end every line and put in one Text$ variable and read the end of txt file.
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

Re: How read the text lines from txt file?

Post by PEB »

I might not be understanding what you want to do, but I think you want to put each line into a table. If that is the case, then you can modify the sample code to something like this:

Code: Select all

TempTable$={}
OpenFile(1, "S:Startup-Sequence")
While Not Eof(1) Do InsertItem(TempTable$, ReadLine(1))
CloseFile(1)
User avatar
Juan Carlos
Posts: 933
Joined: Mon Sep 06, 2010 1:02 pm

Re: How read the text lines from txt file?

Post by Juan Carlos »

PEB wrote:I might not be understanding what you want to do, but I think you want to put each line into a table. If that is the case, then you can modify the sample code to something like this:

Code: Select all

TempTable$={}
OpenFile(1, "S:Startup-Sequence")
While Not Eof(1) Do InsertItem(TempTable$, ReadLine(1))
CloseFile(1)
Thanks, I need this, because I have problems with the translations for V.A.M.P. some special letters with editors and with the compiled change them, and the alternative is open the translation file, and get line to line and to put in the text message variable.
Post Reply