Qbasicnews.com

Full Version: File Names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am constructing a simple Accounts Program Where I save the Balance each time by useing the Code
OPEN "Total.num" FOR OUTPUT AS #1
and I retreive the Balance by opening the file
OPEN "Total.num" FOR INPUT AS #1
Now I want to improve on things by be able to choose a different file name each time
whats the answer
If you're going to ask the user what filename he/she wants, it can be done easily like this:
Code:
INPUT "Filename: ";filename$ 'Get's the filename
OPEN filename$ FOR OUTPUT AS #1
If you want to tag on an automatic extenstion to the filename, you can simply:
OPEN filename$ + ".num" FOR OUTPUT AS #1
And if you want to place the file in a different place with an extension:
OPEN "C:\dir\dir2\dir3\" + filename$ + ".num" FOR OUTPUT AS #1
And, of course the directories I show and the extensions can be different from what I show.