When i use openfile(#,$,false#) is this creating a text file? or a binary?
I think this it always Binary is.
A text editor then interprets only the content legibly to one writes.
A file is just a file. It's what program it is designed to be used with that decides if it's binary or ascii. If you only write readable characters and CR/LF, TAB and similar things it becomes a textfile, if you write random data to it, it's binary. You can even have half of it be a textfile and the other half to be binary.
What are you having problems with?
Indeed, WRITE creates binaries.
I created a program, to build my first binary today, GLMidi.mid
I only needed to use WRITEBYTE, with ASC() for some charaters. And hex, i used the asc2hex$%(#0-255) converter which i added in the codesnipets forum.
Hemlos:
Code?!
:whistle:
You want me to reveal my industrial secrets and i havent even gotten past one note of music lol :P
hehehe ;)
i have the problem, that files with openfile are binarys.....
how can i create a CR/LF in a file (file is opened with OPENFILE (trying to write something on it))
i have tried both posibilities
WRITESTR 2,"\n"
WRITESTR 2,CHR$(13)
but my file is still a one-liner (with the []* sign as CR/LF)
*= the CR/LF of Unixfiles seen on DOS
I usualy use WRITELINE 1, a$ to write textfiles.
Indeed, I recommend writeline as well.
When writing, WRITELINE will put an "\r\n" at the end of the line.
If you want to write UNIX format CR's, use: WRITESTR 1, text$ + "\n"
And dont forget to CLOSEFILE 1
Putfile is a pain, you have to write all the line numbers, makes it difficult to edit a help file or game instructions.
Getfile is ok for grabbing a line, because you can select the line number...good for scripts, just make sure you clear the getfile buffer after use: getfile "",null$
Not to mention that GETFILE / PUTFILE only supports 256 lines wich only makes it useful for very small files. Those few times I have use for it I'm parsing files with 10 000 or 100 000 lines.
use OPENFILE and such. GETFILE is only fr compatibility reasons there.