Get(SystemPlatform) will return a 3 when using a iOS device.
Get(ApplicationVersion) will return "GO_iPad" and the version (for iPad) or "GO" and the version for (iPhone).
Building on swheeler's answer, a rough outline of the script:
IF [ PatternCount ( Get(ApplicationVersion) ; "iPad" ) ≥1 ]
Go to Layout (iPadGOLayout)
ELSE IF [ PatternCount ( Get(ApplicationVersion) ; "go" ) ≥1
Go to Layout (iphoneGOLayout)
Go to Layout (FMProLayout)
1 of 1 people found this helpful
Building on others including a calculation that was posted somewhere here before is a custom function that requires no parameters but will return iPhone, iPad, or Desktop to let you know what kind of device is being used.
02/25/2011 1.0 KLN Original Version
03/21/2012 1.1 KLN Changed Returned Value Of iPhone/iPod to iPhone
PURPOSE: To determine what device type FM is currently running on
Left ( Get ( ApplicationVersion ) ; Position ( Get ( ApplicationVersion ) ; " " ; 1 ; 1 ) - 1 ) = "Go" ; "iPhone" ;
Left ( Get ( ApplicationVersion ) ; Position ( Get ( ApplicationVersion ) ; " " ; 1 ; 1 ) - 1 ) = "Go_iPad" ; "iPad" ;
I call my custom function GetDevice() and have not had any problems using it.
If GetDevice() = "iPad" . . . goto iPad layout
I like it because it makes my code easier to read as to what I want to do; get the device accessing my DB.
Hope others find this helpful.
1 of 1 people found this helpful
Slightly refined version reducing the number of calulation counts
Let ( [
_app = Get ( ApplicationVersion ) ;
_ver = Left ( _app ; Position ( _app ; " " ; 1 ; 1 ) - 1 )
_ver = "Go" ; "iPhone" ;
_ver = "Go_iPad" ; "iPad" ;
The application version function can return "Server" and "Web" and "xDBC" and "Runtime" amongst others. Lumping these into "desktop" might be misleading.
True. But in my case it was more a function of which layout to use. If it was enhanced to include server, web, etc I would change the name of the custom function to something like GetAccess( ) rather than GetDevice ( ) to provide clarity to its purpose.
I like the idea. I was looking for something similar to this. In my case, I do need to also find Web Access status. How would you go about modifying your function to do that?
One thought would be to script a webviewer to go to google then scrape the website to see if it returns any data.
Set Web Viewer["webviewer1";"www.google.com"]
Pause/Resume Script (Duration (seconds): 2)]
Set Variable[$$WebAccess; If (GetLayoutObjectAttribute ( "webviewer1" ; "content" ) =""; "Not Connected"; "Connected")
What do you mean by Web Access status? If you mean are they connected to FileMaker via the web then take a look at Get(ApplicationVersion) it returns various text strings that you could use to determine web access, runtime etc. Don't have them off the top of my head but I am very sure web is something that it retuns.
If you mean do they have a web connection irreagardless of how connected to FM then Silas' tip above should do the trick or I am sure there might be others as well. Never had the need so have not spend too much time thinking about it.
Set a Variable in your startup file ...
Set Variable [$$appVer; Value:
PatternCount ( Get ( ApplicationVersion ) ; "Pro" ) = 1 ; "Pro" ;
PatternCount ( Get ( ApplicationVersion ) ; "Web" ) = 1 ; "Web" ;
PatternCount ( Get ( ApplicationVersion ) ; "iPad" ) = 1 ; "iPad" ;
Once you have the $$appVer variable set then you can set all your layouts using the "Layout name by Calculation" feature and use this case statement:
Go to Layout [
$$appVer="Pro" ; "layoutNamePro" ;
$$appVer="iPad" ; "layoutNameiPad" ;
$$appVer="Web" ; "layoutNameWeb" ;
I am currently using this and works great.
In my case I only have four possiblities if you need you could of course add more. Pro is Desktop display and Web we are using IWP.
Yes. Sorry. I thought that was what you meant. So, my solution is accessed on desktops, iPads, iPhones and on the Web with instant web publishing. It sounded like you had an idea to adapt your custom function to look for users who are logged in over the web. I tried out your function and it works great. Now I would just like to use the same function to change my layouts to ones that have a web specific workflow since not all of my normal scripts will work there, like multiple windows that are precisely overlapped a certain way etc. I am sure I can work out the changes I need to make to the custom function, I just thought I would ask because, like I said, it sounded like you had thought about that already.
I just built a custom function based on Ken Newell and jrenfrew's ideas, and it works like a charm. Thanks guys!
I was looking at Gary Winzeler's idea (farther down in this thread), but I wasn't sure how to "set a variable in the startup file". Is this the same as setting the file options to run a calculation using a script trigger?
Gary, when you say "set a variable in the startup file", what do you mean? Is this the same as running a calculation in a script, triggered when the file is first opened? Can you explain this a bit more for a newbie?
I don't think a variable is as good as a custom function.
Variables can be spoofed by savvy users. That's unlikely but possible. More importantly, there's no centralized location to keep track of variable names. "Did I use $$appVer or $$device.type?" And forget ever changing your variable naming scheme. Even updating your test means you've got to find the script you define the variable in.