|
-
Jul 23rd, 2010, 11:43 PM
#1
Thread Starter
Frenzied Member
QBasic question
Ok, so I decided to go back and use some QBasic just for the sake of some retro programing fun. 
I know in VB6 if you want to check for a file you can use the Dir or Dir$ command. For example:
Code:
dim FileName as string
FileName = "MyFile.txt"
if dir(FileName) <> "" then
print "File exists."
else
print "File is missing."
end if
But QBasic doesn't have Dir or Dir$. So what is the equivalent QBasic command?
-
Jul 24th, 2010, 04:34 AM
#2
Re: QBasic question
Thread moved from 'VB6 and Earlier' forum (which is only meant for VB) to the 'Other BASIC' forum
-
Jul 24th, 2010, 05:57 PM
#3
Thread Starter
Frenzied Member
Re: QBasic question
Why does it seem nobody knows the answer to this?
-
Jul 24th, 2010, 06:15 PM
#4
Hyperactive Member
Re: QBasic question
i don't if there is
a quick search in google, i found this : http://social.msdn.microsoft.com/For...8-fdb33e324ac0
BTW: if you are after good basic interpreter, take a look at this: wxBasic.net
can run on several platforms
-
Jul 25th, 2010, 12:32 AM
#5
Thread Starter
Frenzied Member
Q
 Originally Posted by whatsup
Thanks but I'm not looking to generate a txt file directory listing. I'm looking for the QBasic equivalent of the VB6 command "Dir" or "Dir$". The Dir command in VB6 is a function which when a file name is put into it, its return value is a string containing nothing if the file isn't there, and the name of the file if it is there. It returns it meaning it can be DIRECTLY put into a variable so I can have like:
Code:
dim TestStr as string
TestStr = dir("myfile.dat")
What you have showed me does NOT return a value to QBasic, but rather simply executes the dos command "Dir". I already tried this:
Code:
dim TestStr as string
TestStr = shell dir("myfile.dat")
But that didn't work.
I'm going on the assumption that Dir and Dir$ in VB6 are direct ports of a QBasic command with a similar name (such as DirFind, Find, FileFind, or something like that). But I can't find any QBasic documentation on the internet that names the QBasic equivalent of VB6's Dir and Dir$. But I'm sure such a command exists. Please help me.
-
Jul 25th, 2010, 01:41 PM
#6
Re: QBasic question
VB6 isn't actually descended from QBasic.
QBasic was a fork from an early version of QuickBasic (4.5), meant as a replacement for GW-Basic. It pretty much stagnated where it was. VB took another path, going through Basic Professional Development System (PDS).
VBDOS 1.0 was actually a later version of PDS, and came out just after VB 1.0 for Windows. VBDOS does have Dir$.
The DIR$ functions was introduced in Microsoft Basic PDS for MS-DOS and MS OS/2, version 7.0.
Examples of Loading MS-DOS Directory Listing into an Array
-
Jul 25th, 2010, 11:59 PM
#7
Thread Starter
Frenzied Member
Re: QBasic question
 Originally Posted by dilettante
VB6 isn't actually descended from QBasic.
QBasic was a fork from an early version of QuickBasic (4.5), meant as a replacement for GW-Basic. It pretty much stagnated where it was. VB took another path, going through Basic Professional Development System (PDS).
VBDOS 1.0 was actually a later version of PDS, and came out just after VB 1.0 for Windows. VBDOS does have Dir$.
Examples of Loading MS-DOS Directory Listing into an Array
But does QBasic have an EQUIVALENT command for Dir$?
And what is the difference between QBasic and QuickBasic? I thought they were the same, with the "Q" in QBasic being short for the word "Quick".
-
Jul 26th, 2010, 07:30 AM
#8
Re: QBasic question
No there is no Dir$() or equivalent in QBasic.
QBasic was a stripped down version of an old QuickBasic without a compiler and linker. You are left with the IDE and interpreter, so programs cannot be compiled and thus run much more slowly than compiled QuickBasic programs.
QuickBasic had no Dir$() either.
-
Jul 27th, 2010, 12:40 PM
#9
Re: QBasic question
 Originally Posted by Ben321
But does QBasic have an EQUIVALENT command for Dir$?
And what is the difference between QBasic and QuickBasic? I thought they were the same, with the "Q" in QBasic being short for the word "Quick".
You might be interested in this link.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Aug 7th, 2010, 08:43 AM
#10
Re: QBasic question
Let's see,
If you want to do the following things in Qbasic:
-Check whether a file exists:
Code:
OPEN path FOR INPUT AS #n: CLOSE #n
If the specified file doesn't exist this will cause an error upon execution, which you probably want to cath using the ON ERROR statement.
-Display a list of files in a directory:
Though limited in what it can do, the FILES statement might still be useful to you.
-Write the contents of a directory to a file, which can then be read by your Qbasic program:
Code:
SHELL "DIR path /B>file"
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|