Writing Data Files
BlitzPlus Forums/BlitzPlus Programming/Writing Data Files
| ||
| Hi, it's been a while since I posted here...hope it's still active. Does anyone know if there's a way to get Blitz to write to a text file in a 2D format. Like this... 00110100 00101101 00400201 20301104 38848832 00300500 Whenever i try, it starts a new line every time, like this.... 0 0 1 1 0 1 0 0 etc... Can anyone help me with this? Thank you ^_^ |
| ||
| See thread in b3d section, I've posted an answer there: (but here it is again anyway)
dim myarray(10,10)
;populate array
for x=0 to 10
for y=0 to 10
myarray(x,y)=rand(0,9)
next
next
;create file and write to it
outfile=writefile("test.txt")
if outfile<>0 then
for y=0 to 10
lineoftext$=""
for x=0 to 10
lineoftext$=lineoftext$+str(myarray(x,y))
next
writeline outfile,lineoftext
next
closefile outfile
else
;error occured opening file to write
endif
|
| ||
| Blitz is adding a carriage return and line feed. Most Basics do this but also have an option to suppress it. You can simulate this by doing SeekFile filehandle, FilePos(filehandle) - 2 immediately after writing a line to the file specified by filehandle. That moves the file pointer back two characters, to just before the CR-LF. |