this code works in Script editor, but not if executed from an Applescript Application:
property check_URL : "http://www.google.com" as URL
#this will return the IP address if there is a live connection
try
set dotted_ to dotted decimal form of host of check_URL
return true
on error
return false
end try
.driving me crazy. Wth is going on? worked perfectly in previous versions. I upgraded to 10.10 currently.
Simply crazy. My code doesnt work as app, but only from Script editor.
I wrote a simple script to save as idle-application, so you can test out if you get same results like me.
Please test this out and report back to me, thank you very much
property check_URL : "http://www.google.com" as URL
property dd : 0
on run
set dd to 0
my check_net()
end run
on idle
set dd to dd + 1
set the res to my check_net()
if dd = 12 and res is "Error" then
my quit_me()
end if
return 6
end idle
on quit_me()
quit
end quit_me
on check_net()
try
set dotted_ to dotted decimal form of host of check_URL
set a to "Connected"
#return true
on error err
set a to "Error"
#return false
end try
display dialog a giving up after 3
end check_net
The check_net() handler’s returning the result of the dialog, not the value of a.
Also, the URL you’re checking is compiled into the script as a property, so its values may always be available.
And there seems to be some caching going on too. Even when getting the URL at only at run time, its host and double-dotted form still seem to be available for a while after the router’s switched off.
i use a wifi - mobile - thing therefore ive some problems to connect.
Shane, the little check i do is just a method to have some guarantee that the connection isnt off. Nothing fancy, i know. In the past, this worked fine, so i confide in this little test
Nigel, thanks for the pointers. I removed the property pointing at the url and changed some little bits of the last handler.still no success. The fact is, that previously this piece of code worked flawlessly.
Lets strip everything now.and again: “dotted decimal form of host of “http://macscripter.net/” cannot be transformed in Type URL” (i translated from German)
set dotted_ to dotted decimal form of host of "http://macscripter.net/" as URL