therefore, is there a way to do something like:
Code: Select all
if exists("filename."..wildcard)
Code: Select all
if exists("filename."..wildcard)
Code: Select all
formats = {".gif", ".png", ".jpg"}
file$ = "FILE"
For a = 0 to TableItems(formats) -1
If Exists(file$ .. formats[a])
Print("File exists!")
WaitLeftMouse
End
EndIf
Next
Print("File does not exist!")
WaitLeftMouse
End
Code: Select all
; An "Exists" function which works with (MatchPattern) wildcards, and is case insensitive.
Function p_Exists(f$)
Local d$ = PathPart(f$)
f$ = LowerStr(FilePart(f$))
For s$,t In DirectoryItems(d$)
If MatchPattern(LowerStr(s$), f$) Then Return(True)
Next
EndFunction
; Some examples:
If p_Exists("ram:env") Then DebugPrint("ram:env exists!") Else DebugPrint("doesn't exist")
If p_Exists("ram:clip*") Then DebugPrint("ram:clip* exists!") Else DebugPrint("doesn't exist")
If p_Exists("ram:*boards") Then DebugPrint("ram:*boards exists!") Else DebugPrint("doesn't exist")
If p_Exists("ram:test*file") Then DebugPrint("ram:test*file exists!") Else DebugPrint("doesn't exist")
If p_Exists("*.hws") Then DebugPrint("*.hws exists!") Else DebugPrint("doesn't exist")