This function 'dirExists' is similar to built-in FB command 'fileExists'.
Really helpfull in case of your own big dBs managing, etc.
Code: Select all
function dirExists(byval somePathToTest as string) as integer
'return values as written on wikiDoc 6.8.2016
'0 -> folder exists Other values -> NON existing folder
Dim As String whereWeCall=curdir
Dim As Integer result=-1
result=ChDir(somePathToTest) 'try to change a folder
ChDir(whereWeCall) 'return to calling point ! MUST BE
return result
end function
edited -
Here is version for ANY custom logics values of integer,
and line #include "vbcompat.bi" is not needed in this case ;)
Code: Select all
(...)
Dim shared As Integer myTrue=1,myFalse=-1 'global custom True/False logic values of integer !
'you can set it as you want, e.g. 1/0 or 1/-1 or 0/1 or 0/-1 ... or whatever
(...)
declare function dirExists(byval somePathToTest as string) as integer
(...)
function dirExists(byval somePathToTest as string) as integer
Dim As String whereWeCall=curdir
'myTrue,myFalse are a global integer values for TRUE/FALSE logic of CUSTOM
ChDir(somePathToTest) 'try to change a folder
/'
'multi line code
if curdir<>whereWeCall then
return myTrue 'folder changed , so exists
else
return myFalse 'No change , so Not existing
end if
'/
'or one line code
if curdir<>whereWeCall then return myTrue else return myFalse
ChDir(whereWeCall) 'return to calling point ! MUST BE
end function
(...)
Code: Select all
? dirExists("augy-11") 'or
? dirExists("/home/knoppix/sGUI") 'or
if dirExists("augy-11") then ... 'or
if not dirExists("augy-11") then ... 'or
if dirExists("augy-11")=myTrue then ... 'or
if dirExists("augy-11")<>myTrue then ...
(...)