• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange Errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange Errors


  • Subject: Re: Strange Errors
  • From: "Stockly, Ed" <email@hidden>
  • Date: Mon, 10 Aug 2015 17:31:19 +0000
  • Thread-topic: Strange Errors

You only need to declare your handler once, and your script calls it multiple time. But if you set a variable to the handler, you only need to call it once. It's best to put your handler at the end of the script, not in the middle.


It looks like there's some redundancy you don't really need. Here's a version that compiles and runs, but the ping part doesn't seem to be working


property myIPAddress : ""

display alert ¬

"What would you like to do" buttons {"RetrieveYourIP", "PingIPOrDomainName", "Quit"} ¬

cancel button ¬

"Quit" --with title "Select a network option"


set the button_pressed to the button returned of the result

#Buttons

if the button_pressed is "RetrieveYourIP" then

say "Retrieving Your IP address, this may take a moment." without waiting until completion

set myIPAddress to WanIP()

display alert "Your IP Address is" & myIPAddress & "And has been copied to your clipboard."

set the clipboard to myIPAddress

else

if the button_pressed is "PingIPOrDomainName" then

set IP_address to ""

set dialog_1 to display dialog "Enter IP Address:" default answer myIPAddress with title "Ping IP Address" buttons {"OK"} default button 1

set the IP_address to the text returned of dialog_1

try

do shell script ("ping -c 2 " & IP_address)

display dialog "Host is up" buttons {"OK"} default button 1 with title "Host Status"

on error

display dialog "Host unreachable" buttons {"OK"} default button 1 with title "Host Status"

end try

if the button_pressed is "PingIPOrDomainName" then

set IP_address to ""

set dialog_1 to display dialog "Enter IP Address:" default answer myIPAddress with title "Ping IP Address" buttons {"OK"} default button 1

set the IP_address to the text returned of dialog_1

try

do shell script ("ping -c 2 " & IP_address)

display dialog "Host is up" buttons {"OK"} default button 1 with title "Host Status"

on error

display dialog "Host unreachable" buttons {"OK"} default button 1 with title "Host Status"

end try

end if

display alert "Thank you for using this application. If you liked using this application, please consider donating by visiting the application website and clicking on donate. Any amount donated would be greatly appreciated.

Would you like to file a bug report? Visit the main application website?Or quit?" buttons {"FileBugReport", "VisitApplicationWebSite", "Quit"} cancel button "Quit"

set the button_pressed to the button returned of the result

#Buttons

if the button_pressed is "VisitApplicationWebSite" then

set VisitApplicationWebSite to "http://firestar-hosting.com/mac"

open location VisitApplicationWebSite

else

if the button_pressed is "FileBugReport" then

set FileBugReport to "http://firestar-hosting.com/mac/bugs"

open location FileBugReport

end if

end if

end if

end if


on WanIP()

set WIP to missing value

set siteList to {"http://checkip.dyndns.org/", "http://whatismyip.com", "http://www.whatismyipaddress.com", "http://ipid.shat.net/", "http://www.edpsciences.comhtbin/ipaddress", "http://www.showmyip.com/"}

repeat with thissite in siteList

try

set WIP to item 1 of paragraphs of (do shell script "curl " & thissite & " | tr -cs '[0-9\\.]' '\\012' | awk -F'.' 'NF==4 && $1>0 && $1<256 && $2<256 && $3<256 && $4<256 && !/\\.\\./'")

if WIP is not missing value then exit repeat

end try

end repeat

return WIP

end WanIP

 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Strange Errors (From: Daniel Chavez <email@hidden>)

  • Prev by Date: Re: Strange Errors
  • Next by Date: Re: Strange Errors
  • Previous by thread: Re: Strange Errors
  • Next by thread: Re: Strange Errors
  • Index(es):
    • Date
    • Thread