Get(ConnectionState) is only used to determine whether FM Pro or FM Go is connected to the host using SSL.
0 = no network connection
1 = FileMaker Server with SSL disabled or FileMaker Pro host
2 = secured connection but the server name does not match the certificate (this is default for FileMaker Server)
3 = secured connection with a verified server name in the certificate
I'm not aware of a way to test the connection strength. I'm sure it's possible, but I haven't done it before.
To test for an internet connection, you can use XML. Add table (lets call it ConnectionTest) and add a global field. Make an XML file that has your global field and set it to 1. Place on external webserver.
Add a script that sets your global field to 0, then imports from XML via http. If you have an internet connection then your global field will be set to 1 from the import, which means you are connected to the web. If you're not connected to the web then the global field will be 0.
This would not tell you connection strength, but it would let you know if a connection is possible. In your scripts that are internet dependent, you could run this script at the beginning to ensure a connection is present.
Hope this helps.
Get ( ConnectionState ) is not only used to determine whether a connection to a FileMaker host is using SSL. I use it left and right to do different things depending on whether the file is hosted or running locally on a device. For example, I might clear all global fields in a file OnLastWindowClose so that whatever was left in them doesn't become a default value the next time the file is opened, but only if the file is running locally. (If the file is hosted, global field values at the time of closing are discarded.) For another example, I have a script that saves a compacted backup copy of a file I'm working on locally; this neither works nor makes sense when the file is hosted, so it exits early and its custom menu item is hidden whenever Get ( ConnectionState ) > 0.
Get ( ConnectionStrength ) would be handy, though.
Excellent points made jbante. You're right I shouldn't have used "only" in there.
I have file the refeernces a hosted db as an external source. Some scripts shoul not run if the hosted db cannot be contacted
I have done something similar to eshoshin's method for checking the connection before running a script that requires that it works.
----Get(Connectionstate) in IOS can return 1 when you have moved out of cellular range -- it does not actually test the connection.
In My IOS app I would like to have an on-timer script running every 30 secs , say that checks the connection , and then warns the user if it has dropped.
Or if it find you can now connect, reopen and connect to the hosted db. Unfortunately I cannot see how to make that happen witout closing and re-opening the file -- even executing Open File to open the hosted file does not induce the local file to realize its external source is available again.
I'd like to have the reconnection happen seamlessly for the user - my thinking at present is that that is not possible -- but I would love to hear any ideas people have on this?
Your timer script could go to a layout with a web viewer and point it at a web page where you know what would be returned. If the contents get loaded you know you have a valid net connection (but not necessarily a connection to your hosted db). Of course, if FileMaker hasn't cached your web viewer layout you'll probably get an error right there. You could get around that by going to that layout in your startup script.
That's not the issue: I know how to find out if I am connected.
What I want to do is to reconnect seamlessy when in entering into into cellular range again.
Note this app is open all day, with sales people going in and out of cellular data range.
How about using Open URL with the FMP:// protocol to reopen your database? That effectively gets you out of FM temporarily (to Safari on iOS) - wondering if that will make Go check the connection and re-open..
Mark that doesn't work. It opens the file just fine but fields from that file still display aas "File Missing" in layouts in the local file.
But I have addpated you earlier suggestion, using "insert from URL" pointing to a file in the web root on the same server as FMS. If that step genretes an error, we are not connected.
I believe if run a script to do that check in a timer (say every 5 sec) it can call script a second file when it newly finds the connection to be working. (In fact I wait for it to work 6 times consecutuvely -- nearest thing I can think of to a signal strength meter !) That script would ask the user if they want to close reopen the first file, and would then do that. Not seamless, but less messy than having to close and reopen manually.