Dosser - Programmers Heaven

Howdy, Stranger!

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

Categories

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.