Hi,
If a user enter an invalid path for saving a file my script ends with this error: http://pages.infinit.net/pgx/ERROR.jpg
so is there a way to make sure the path is correct?
Thank you.
Pierre
How to know if a directory or Path is valid?
Re: How to know if a directory or Path is valid?
Have a look at this https://www.hollywood-mal.com/docs/html ... dling.html.
It doesn't helps you to check if the path is correct, but if the functions fails the script won't abort!
You can check the error yourself and message the user to choose a valid path.
It doesn't helps you to check if the path is correct, but if the functions fails the script won't abort!
You can check the error yourself and message the user to choose a valid path.
Re: How to know if a directory or Path is valid?
You can check if the volume is valid with the HaveVolume() function. And if you then need to check for a deeper directory structure, you can use the Exists() function.
Re: How to know if a directory or Path is valid?
If it's OK to get the "Please insert volume..." requester for wrong volume names (and give a user a possibility to mount/insert the requested device), just check the path with the Exists() function, and forget the HaveVolume() function.
But if you want it to quietly check if both volume and path are valid, you could do a simple function like this (quickly pulled together, might not be optimal, and works only on Amiga compatibles in this form):
But if you want it to quietly check if both volume and path are valid, you could do a simple function like this (quickly pulled together, might not be optimal, and works only on Amiga compatibles in this form):
Code: Select all
Function p_IsValidPath(path$)
Local volume$ = PatternFindStrShort(path$, "(.+:)")
Return(HaveVolume(volume$) And Exists(path$))
EndFunction
Re: How to know if a directory or Path is valid?
Thank you... I'll check that this weekend.
Bye!
Pierre.
Bye!
Pierre.
Re: How to know if a directory or Path is valid?
Hi,
The command HaveVolume() work perfectly in my script:
PathOk = HaveVolume(PathPart(f$))
If PathOk = 0
moai.Request("", "Le chemin ou répertoire n'existe pas!", "OK", "error")
Return
EndIf
Thanks again for your precious help.
Bye!
Pierre
The command HaveVolume() work perfectly in my script:
PathOk = HaveVolume(PathPart(f$))
If PathOk = 0
moai.Request("", "Le chemin ou répertoire n'existe pas!", "OK", "error")
Return
EndIf
Thanks again for your precious help.
Bye!
Pierre