Ping or Retrieve IP Address

In my existing script, I wish to add the capability to either ping an address, or retrieve an LAN IP address.

#Script Begin
display alert "Your IP Address is" & WanIP() & "And has been copied to your clipboard."
set the clipboard to WanIP()
on WanIP()
	set WIP to missing value
	set siteList to {"", "", "", "", "http://www.edpsciences.comhtbin/ipaddress", ""}
	repeat with thissite in siteList
			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
set VisitApplicationWebSite to ""
set FileBugReport to ""
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"}
set the button_pressed to the button returned of the result
if the button_pressed is "VisitApplicationWebSite" then
	open location VisitApplicationWebSite
	if the button_pressed is "FileBugReport" then
		open location FileBugReport
		if the button_pressed is "Quit" then
			error number -128
		end if
	end if
end if
#Script end

Pretty much what I want is the script to ask the user whether they want to ping or get the IP. If they select ping, bring up an edit box to put an address in and have a button that says ping, then return the result.
if they select the IP address option, it continues as originally set out in the script code above.
Hopefully this isn’t to difficult, and I’ve explored the option to set the question bit. But stuck just with it.
Thanks for any help you can provide.


This should get you started.

set ipaddr to ""
	set {btn, txt} to {button returned, text returned} of (display dialog "Ping ip address?" with title "ip Validator" default answer ipaddr buttons {"Cancel", "Ping"} cancel button 1 default button 2)
on error
	set btn to "Cancel"
end try

if btn = "Ping" then
	if txt ≠ "" then
		display dialog "About to ping ip address: " & txt
		-- ping
		-- show dialog with result, (read the dictionary of Standard additions.)
		-- show error message
	end if
end if

Ah, that’s how that works. Thanks a lot for the help.