Problem with ReadLine

Blitz3D Forums/Blitz3D Beginners Area/Problem with ReadLine

Elgen(Posted 2004) [#1]
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???


Difference(Posted 2004) [#2]
Post your code.


Elgen(Posted 2004) [#3]
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()


Elgen(Posted 2004) [#4]
now, when i do this, the value of global planet$ is "" accordingly to the debugger!


TomToad(Posted 2004) [#5]
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.


clownhunter(Posted 2004) [#6]
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.


VIP3R(Posted 2004) [#7]

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.


Techlord(Posted 2004) [#8]
...


Curtastic(Posted 2004) [#9]
it works for me


BlackJumper(Posted 2004) [#10]
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...