ReadString problem?

BlitzMax Forums/BlitzMax Beginners Area/ReadString problem?

Helios(Posted 2005) [#1]
Right, well i have some files i made in blitz+, and alot of the data in them used the old writestring command, what im wondering is how i would read them this time with the new ReadString seeing as that one now has a length command?


Beaker(Posted 2005) [#2]
[EDIT: don't do it this way - I thought you meant ReadLine() ]
Perhaps, read the whole file into the string (using the length of the file), and then break it up from there.


Perturbatio(Posted 2005) [#3]
Function RetroReadString:String(Stream:TStream)
	Local strLen:Int = Readint(Stream)
	Return ReadString(Stream, strLen)
End Function


myStream : TStream = OpenFile("c:\testread.txt")

Print RetroReadString(myStream)

CloseFile(myStream)

End



Sarge(Posted 2005) [#4]
i dont know if this is what your looking

'Load SourceFile

sourcefile$=Input("SourceCode:")
source = OpenFile(sourcefile$,True,True)

'Create TList

bmx:TList=CreateList()

find$="TList"

Repeat
'Read File Then Put Code Into Tlist

code$=ReadLine(source)
Print code$
ListAddLast bmx,code$

output=WriteStream("output.txt")

'Find Each Line In A Tlist Then Export New SourceFile

For a$=EachIn bmx
WriteLine output, a$
Next

Until Eof(source)



Helios(Posted 2005) [#5]
Thanks guys ^_^, ill check them out!


Perturbatio(Posted 2005) [#6]
I don't have B+ btw, but I do have B3D, I am assuming that they write strings in the same way (Int size then characters)


Helios(Posted 2005) [#7]
Yep it works, THanks ^_^