Graham Samuel wrote:

I have a path in a variable say myPath, and I execute

create folder myPath

sometimes the folder can't be created (if the directory is protected etc) and if I execute the above in the message box in these circumstances, I see the text

   can't create that directory

But if I do this by script, this text doesn't seem to be in 'the result' or in 'it' (which appears to contain 'OK' even if the create hasn't worked), so where is this text - ? The 2.7.0 docs (dictionary and PDF) are silent on the matter. As 'create' is not a function, I don't see any other way for it to return a value.

Clearly I can produce a workaround by checking if the folder exists immediately after trying to create it, but how does 'create' show its result"?

That's the easy part, "the result":

   create folder myPath
   if the result is not empty then
     answer the result
     exit to top
   end if

The hard part is determining exactly what went wrong. When a file or folder creation error happens, in most cases all the result says is "can't create file" or "can't create folder" with no further explanation. How do you advise your users?

The trick is the sysError function, which queries the OS to obtain the specific error code associated with the failure. So you could do something like:

   create folder myPath
   if the result is not empty then
     answer the result &" (" sysError() &")"
     exit to top
   end if

That'll give you a specific error code:

   can't create directory (43)

That at least allows your users to give you an error code number when they call your tech support line, but I'm a big fan of reducing those calls altogether when I can, and that means finding out the meaning of all the OS error codes for each supported platform, and building in a lookup table to present more meaningful info to the user.

A while back I posted a request for pointers to those codes:
<http://mail.runrev.com/pipermail/use-revolution/2006-February/076890.html>

I've turned up some, but I have too many for Win32 and very few for OS X. While I winnow the Win list down to a manageable subset of common culprits, if someone out there has a link to OS X error codes I'd certainly appreciate it, and show that appreciation with a modest library to make those lookups.

--
 Richard Gaskin
 Managing Editor, revJournal
 _______________________________________________________
 Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to