Qbasicnews.com

Full Version: OPEN
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am opening a file for output
Code:
OPEN "bob.txt" FOR OUTPUT AS #1
PRINT #1, "Hi wuts up?"
CLOSE #1

But when i make it an EXE using QB 4.5 it doesn't work.
Maybe it's a sign that you aren't Jesus.
You sure?
try write #1 instead of print #1
Quote:I am opening a file for output
Code:
OPEN "bob.txt" FOR OUTPUT AS #1
PRINT #1, "Hi wuts up?"
CLOSE #1

But when i make it an EXE using QB 4.5 it doesn't work.

Why not use instead:

OPEN "bob.txt" for BINARY AS 1
PUT 1, ,"Hi wuts up?"
close 1

and not worry about it? Also, if you are using an OPEN x FOR OUTPUT construct, why not use the WRITE 1, text instead of PRINT 1...? If you use the WRITE format instead of PRINT, the data will be comma deliminated...which is easier to read when you are retrieving your data.

cheers
I tries it with binary but when i turn it into an EXE it doesn't work
Quote:I tries it with binary but when i turn it into an EXE it doesn't work

Whitetiger...I just compiled your original 3-line prog...works fine...I can read the test file no prob...FYI
There's nothing wrong with that program as written. Are you absolutely sure *that's* the program you're trying to make an executable of? Humor me. Save your program. Let's say you called it "program.bas", for definitiveness. Open a DOS window. CD to the directory where that file is. Do

BC PROGRAM /O;
LINK PROGRAM;

If you don't get any error messages from BC or LINK, try running PROGRAM.

Now that I've typed all that, as I was typing the "/O", above, it occured to me that I should've asked what you meant by "doesn't work". Does the executable get made, or do you get compilation/LINK errors. If it gets errors when it runs, what errors did you get? (I'm wondering if the only problem is that you didn't make a stand-alone executable and your program can't find BRUN45.EXE.)
there were no errors. i bet that was it.
I don't know but I think you should

cls

Screen 0