Internet Connection Test

0

Don’t you hate it when your FileMaker solution freezes because your WiFi has dropped. It hangs about for ages before displaying an error message telling you that you have no internet connection. Well what if there was a way to check for an internet connection that is native to FileMaker? There isn’t a way…

However FileMaker works great with AppleScript. And you are able to test for a live connection with AppleScript and then import the result to FileMaker.

Normal AppleScript

Start

repeat with i from 1 to 5
try
do shell script “ping -o www.apple.com”
exit repeat
on error
delay 5
beep
if i = 5 then error number -128
end try
end repeat
say “Connected”

End

That is one way of testing for a live internet connection using just AppleScript on its own.

With a couple of modifications you are able to use something similar to this within FileMaker to perform an internet connection test.

The modified AppleScript looks like this…

Modified AppleScript

Start of Script ( do not copy this line )

try
set thePing to do shell script “/sbin/ping -o -c 5 www.google.com”
on error
set thePing to “error”
end try

tell application “FileMaker Pro Advanced”
if thePing is not “error” then
set cell “Internet” to “true”
else
set cell “Internet” to “false”
end if
end tell

End of Script ( do not copy this line )

You can now copy and paste the above code into FileMaker. But first, you need to create a new FileMaker script and create a field to store the result in.

First create a new script and add the script step “Perform AppleScript” found under the miscellaneous category. Edit the Perform AppleScript settings and set it to ‘Native AppleScript’. Copy the above code into that box!

Configure AppleScript

The main section to note in the AppleScript is the part beginning with ‘tell application “FileMaker Pro Advanced” ‘. This is the part where your result is given to FileMaker. I recommend configuring a global field to store the result in. The AppleScript will return “true” or “false” depending on whether you have an internet connection or not. For simplicity I called this field “Internet” which is referred to in the AppleScript as a cell. Whatever you call you field you must change the AppleScript accordingly.

After you have created the script and created a field to store the result in you are good to go!

Because the result is stored you can perform calculations on it within FileMaker! I use this to hide particular items on a layout and to make certain buttons available or unavailable.

Enjoy creating solutions of your own!

FavoriteLoadingAdd to favorites

Leave a Reply