Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dosser

Hadji_13Hadji_13 Posts: 274Member
Hi
Can anyone tell me how to detect if a directory exists, and also if files exist in a specified location. I just need to know yes or no.

Ta

Hadji
----------------------------------------------------
The solution to the problem changes the problem

Comments

  • sk8er91sk8er91 Posts: 4Member
    The code for qbasic??
    the code is
    -----------------------
    if (file here) then goto exist
    goto end
    exist:
    print "That file exists!"
    end:
    end
    -------------------------
    i dont know about the directory part though...

    : Hi
    : Can anyone tell me how to detect if a directory exists, and also if files exist in a specified location. I just need to know yes or no.
    :
    : Ta
    :
    : Hadji
    : ----------------------------------------------------
    : The solution to the problem changes the problem
    :

    [size = 5] [purple] Qbasic [/purple][/size = 5]
    :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :)

  • VB5begginnerVB5begginner Posts: 66Member
    To find out if a directory exists in QBasic it would be easiest to make a function like this:

    [b]--Code for QBasic 1.0--[/b]
    [code]
    FUNCTION DirExists(DirName AS STRING)
    ON ERROR GOTO NonExistant
    CHDIR DirName
    ON ERROR GOTO 0
    DirExitsts = 1

    EXIT FUNCTION
    NonExistant:
    DirExitsts = 0
    END FUNCTION
    [/code]


    [b]--Code more adapted for QBasic X (version 7)--[/b]
    [code]
    FUNCTION DirExists(DirName AS STRING)
    ON LOCAL ERROR GOTO NonExistant
    CHDIR DirName
    DirExitsts = 1

    EXIT FUNCTION
    NonExistant:
    DirExitsts = 0
    END FUNCTION
    [/code]


    Then after adding the function to check if the directory exists use this code:
    [code]
    IF DirExists("[red]Drive:Directory[/red]") THEN PRINT "Directory Exists"
    IF NOT DirExists("[red]Drive:Directory[/red]") THEN PRINT "Directory does not exist"
    [/code]


    [hr]

    : The code for qbasic??
    : the code is
    : -----------------------
    : if (file here) then goto exist
    : goto end
    : exist:
    : print "That file exists!"
    : end:
    : end
    : -------------------------
    : i dont know about the directory part though...
    :
    : : Hi
    : : Can anyone tell me how to detect if a directory exists, and also if files exist in a specified location. I just need to know yes or no.
    : :
    : : Ta
    : :
    : : Hadji
    : : ----------------------------------------------------
    : : The solution to the problem changes the problem
    : :
    :
    : [size = 5] [purple] Qbasic [/purple][/size = 5]
    : :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :)
    :
    :

Sign In or Register to comment.