Results 1 to 10 of 10

Thread: QBasic question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    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?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: QBasic question

    Thread moved from 'VB6 and Earlier' forum (which is only meant for VB) to the 'Other BASIC' forum

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Re: QBasic question

    Why does it seem nobody knows the answer to this?

  4. #4
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Q

    Quote Originally Posted by whatsup View Post
    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
    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.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Re: QBasic question

    Quote Originally Posted by dilettante View Post
    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".

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  9. #9
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: QBasic question

    Quote Originally Posted by Ben321 View Post
    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

  10. #10
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,945

    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:
    Code:
    FILES "pattern"
    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
  •  



Click Here to Expand Forum to Full Width