Problem with ReadLine

Blitz3D Forums/Blitz3D Beginners Area/Problem with ReadLine

Im trying to load some lines from a txt file, but I am having problems...

I use the
----
plname = ReadFile("planets.txt")
----
command to open the txt file, then i use the
----
Read1$ = ReadLine( plname )
Read2$ = ReadLine( plname )
Read3$ = ReadLine( plname )
Read4$ = ReadLine( plname )
----
to load the lines into variables.

When i use the print command (like print Read1$) it works
perfectly, printing the line on screen. But when i try to
copy the read1$ to the global planet$, and send it to an other computer, it turs out empty.

When i check the global planet$ in the debugger, its empty!
But if i print it, it turns out right.

Whats going on???

Post your code.

Global planet$

; Open the file to Read
plname = ReadFile("planets.txt")


Read1$ = ReadLine( plname )
Read2$ = ReadLine( plname )
Read3$ = ReadLine( plname )
Read4$ = ReadLine( plname )

planet$=Read1

Print Read1
Print Read2
Print Read3
Print Read4
Print
Print planet$

WaitKey()

now, when i do this, the value of global planet$ is "" accordingly to the debugger!

There seems to be a problem with the debugger itself. When I put a Stop at the beginning of the program, then step through it line by line, everything in the debugger updates properly, but if I just let it run, then Read1 etc... and Planet all have "". The program itself works properly though, so it must be a debugger problem.

Don't you need to have an OpenFile() command somewhere? I thought you had to open the file, then read it. I could be mistaken though.


Don't you need to have an OpenFile() command somewhere?


No, the ReadFile command is being used here which allows read only operations on a file.

OpenFile allows you to 'update' the contents of an existing file. Look at your docs to see an in-depth explanation of this.

...

it works for me

works for me in B3D V1.88 - could it be a version problem ?

hmm... just spotted

and send it to an other computer, it turs out empty


perhaps you could elaborate on this...