Qbasicnews.com

Full Version: New file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok i am writeing a program what is basicly a external script creator (for softwear called playerworlds) it will ask then questions and then add there awnser to the script where it belongs

but to cut to the chase i need to create a new file how would i do this?
correct me if i'm wrong but you just save the file as normal as though it was there
ohh and a nother question

i want it to come out in plain text will it do it auto maticaly and can i get some examples of what you mean GDM
sorry a little off topic but, player worlds is not good. sorry again
To create a new file (like GDM said)
Code:
OPEN filename$ FOR INPUT AS #1
You can use other file access methods to create a new file (BINARY, RANDOM)

To put text into a file: If you've opened up a file for sequential input (as above), you can use this:
Code:
PRINT #1, "Crap you want to put in the file. Line by line"
It will put the string into the file... line by line. Smile
so
Code:
PRINT #1, "Hello world"
PRINT #1, "is far too common for me"
PRINT #1, "to ever use"
would produce a file that looks like this
Code:
Hello world
is far too common for me
to ever use

HTH

~Phydaux
why not this
Code:
PRINT "HI" + CHR$(13) + "BYE"
Well... it would be PRINT #1 for a start, and also you need a CHR$(10) and also if the line becomes longer than 256 characters you'll have trouble compiling it. But for short records you are right, it'll work fine.
yes i was rite

wahoo
Quote:why not this
Code:
PRINT "HI" + CHR$(13) + "BYE"
Well apart from all the problems Oracle mentioned, you can't stick commands between "HI" and "BYE" if you needed to.
Quote:To create a new file (like GDM said)
Code:
OPEN filename$ FOR INPUT AS #1
You can use other file access methods to create a new file (BINARY, RANDOM)

I don't think INPUT will work creating a new file:
INPUT: Open file for reading if it exists
OUTPUT: Open new file for output, delete and create new if exists
RANDOM: Open file for input/output, if not exists create null file
BINARY: Open file for input/output, if not exists create null file

When using INPUT and trying to open a non-existing file, you'll get a file not found error.