LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
You can check if the file exists. A problem is that a file name might actually be URL-encoded. E.g. if a web master made a mistake and used a URL-encoded file name for a file, which was downloaded by a user who kept the name encoded. This should work:
if there is a file myUrlEncodedFileName then
put false into myUrlEncoded
else if there is a file urlDecoded(myUrlEncodedFileName) then
put true into myUrlEncoded
else
put "error" into myUrlEncoded
end if
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark,
Thank again for help
The exists file way don't work if the filename is urlencoded, (myUrlEncoded = false)
I tried also to compare file name and item 1 of the detailed file, but it don't work if file name contains space or diacritical char.
I have added "+" to the list of chars to search in file name and it seems work with urlEncoded file name and file name that contains space or diacritical char
Why do you conclude that the "exists file way don't work if the filename is urlencoded"? I'd say it works.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Are you sure that your file paths are urlEncoded? Where do you get your paths from? If it returns either true or false, it means that the script works correctly because the file has been detected. If the file can't be found, e.g. because there is an error in the file path, the script returns "error". Why is there still a problem?
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Either way, since you report that myUrlEncoded is false and not "error", it works. I don't understand what the problem is.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Either way, since you report that myUrlEncoded is false and not "error", it works. I don't understand what the problem is.
When a file name is urlencoded, myUrlEncoded = false and i don't know if I have to urldecode it to get name with diacritical and space chars.
Jacques,
Yes, this way works fine in this four cases (what else ?)
• File name with a diacritical char or space not urlEncoded: "la fée"
• File name without diacritical char or space not urlEncoded: "maison"
• File name with a diacritical char or space urlEncoded: "la+f%8Ee"
• File name without diacritical char or space urlEncoded: "maison"
I asked you about the source of those file names. This may make a big difference.
Can you give me an example of a case in which my script returns false (rather than "error")? It is very strange, because it means that the file exists on disk with a urlEncoded file name. Are you sure that in this case the urlEncoded file name isn't the same as the urlUnencoded filename, because the filename has no special chars?
Jacque's solution won't work. For example, if your actual filename contains a +, her approach will report that the filename is encoded. You could take care of all peculiarities by checking for each special character, but it is much easier to simply check that the file exists.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
You still haven't explained where you file names come from. One way or another, LiveCode must receive a list of urlEncoded file names. As long as you don't tell me the source of this list, I can't do any more for you.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode