Thread: Help with BASIC
View Single Post
HorvatM

JCF Member

Joined: Jul 2007

Posts: 70

HorvatM is doing well so far

Aug 11, 2008, 04:26 AM
HorvatM is offline
Reply With Quote
I am an experienced BASIC programmer. The problem is, that I've never really found any other solution to opening files easier than typing the path and file name. However, one suggestion is (albeit not really elegant):

Tell the user that the files he/she wants to work with must be in the directory of the program. Then, you can make him/her write his/her files in a file with a listing of all the files, which is read by the program when choosing a file. In Microsoft QBasic, reading that file would be like this:

Code:
OPEN "Filelist.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
  Counter = Counter + 1
  INPUT #1, FileName$(Counter)
  PRINT FileName$(Counter)
LOOP
CLOSE #1
Of course this only works if the files are one per line, and they are written with double quotes before and after their names (such as "MyFile.txt"). To save disk space by two bytes for each file and to simplify the process for the user not having to enter each file in quotes, use LINE INPUT in place of INPUT.

You can also sort the files by name, but I'm not going to deal with this at the moment.

Note that I have only tested these techniques on Microsoft QBasic. Your BASIC interpreter/compiler may use different commands for dealing with files.

Hope this helps!
__________________
Jazz 2 Utilities

Last edited by HorvatM; Aug 11, 2008 at 04:28 AM. Reason: A few errors.