Program error -1312

Hey,
I got this simple script that mounts a smb volume


set myDomain to "domain"

set promptText to "Username"
set user1 to (display dialog promptText default answer "")
set myName to text returned of user1


mount volume "smb://" & myDomain & ";" & myName & "@server/" & myName

It works fine when I run it in the script editor. But as soon as I make a application I get the following error.

What´s the problem?
Thanks!
Regards,
Tobbe

I can’t test this because I do not have access to an smb server. But you can try wrapping the script in a run handler like this…

on run
set myDomain to "domain" 
set promptText to "Username" 
set user1 to (display dialog promptText default answer "") 
set myName to text returned of user1 
mount volume "smb://" & myDomain & ";" & myName & "@server/" & myName
end run

Then save it as an application.

Thanks Greg, it worked. :smiley:
Why do I need the run handler?
Regars,
Tobbe

It shouldn’t really be necessary. I wonder if it was just the fact that you saved the script again, which may have cleared some corruption or voodoo from the previously saved file. If you remove the run handler, does the error return?

– Rob

Hey,
I removed the run handler and the error is back. Oh well, it works with the run handler so we´ll have to live with that. Not a big problem but still it would be nice to know why it doesn´t work without it.
Strange.
Thanks!
Regards,
Tobbe

Yes, strange indeed. Ok Greg, you have some splainin’ to do. :stuck_out_tongue:

– Rob

I’m not sure why it happens, but I have run into the same problem that Tobbe noted “it will run from the editor, but not as a saved app”. Wrapping it in a run handler has always seemed to help in those cases.
I haven’t seen that error in a long time and I was able to compile and run Tobbe’s script – it errored with “-36 I/O errors” – most likely because I am not using smb.

Tobbe, what version of the Script Editor & AppleScript are you using? From the “Script Editor” menu via “About Script Editor”

I have SE 2.0 v36
AppleScript v1.9.1

I´m using SE 1.9 and AS 1.9.1

That strange error I got seems to turn up at random. I get it quite alot, even with the run handler. :?
Could it be my versions of SE and AS?
Doesn´t seem to be connected to the run handler anymore, must be some blackmagic “voodoo” stuff going on.

Thanks!
Tobbe