
-----------------------------------
jrblast
Tue Feb 07, 2006 5:24 pm

Datafile write troubl
-----------------------------------
For my block breaker game which I'm making I also want to make a level maker (I have it so that it reads the level from a datafile) but when I write the level, lots of extra spaces show up and the new line char shows up as a square...not a new line... heres the code, is there anything wrong? is it a bug? or what....

    var lineBreak : string := chr (10)
    var clr : string                    %variable for colour
    open : streamIn, (file + ".txt"), write, seek
    seek : streamIn, 0
    for y : 1 .. rows
        for x : 1 .. cols
            if blockColour (x,y)  0
            end loop
            delay (100)
        end for
        write : streamIn, lineBreak
    end for

    close : streamIn

I'll attatch an example of a file it created...a 30 KB text file o.O(Oh, and the blockColour variable is a  2-D array). The good news is its not as bad as my little mistake yesterday...where i CREATED 19, 500 text files. LMAO

-----------------------------------
Cervantes
Tue Feb 07, 2006 6:08 pm


-----------------------------------
Try it with put instead of write.

Also, there's no point in seeking to the beginning.  When you open a file without giving it mod ability, it clears the file and begins writing from the beginning.

-----------------------------------
MysticVegeta
Tue Feb 07, 2006 6:37 pm


-----------------------------------
I think read and write are more for files with nontext extension...? perhaps. not sure though.

-----------------------------------
jrblast
Tue Feb 07, 2006 10:33 pm


-----------------------------------
Try it with put instead of write.

Also, there's no point in seeking to the beginning.  When you open a file without giving it mod ability, it clears the file and begins writing from the beginning.

Okay, that seems to have worked. Thanks :)

@MysticVegeta: Hmmm...That makes sense I guess.

-----------------------------------
codemage
Wed Feb 08, 2006 8:50 am


-----------------------------------
Put & get make raw text style output.  
That makes error checking / debugging your output much, much simpler.

-----------------------------------
Cervantes
Wed Feb 08, 2006 5:31 pm


-----------------------------------
I think read and write are more for files with nontext extension...? perhaps. not sure though.
You can give a file any extension you want.  It doesn't change the contents of the file.  However, using read and write will not produce readable output, as they are for random access, and work in a binary format, rather than standard ASCII.
