This post is all about creating a variable that will detect what type of device you are using. It will tell you if you are on an iPhone, iPad, Mac, PC or Web Application.
So to begin, create a script and call it something recognisable!
For your first script step, use the ‘Set Variable’ option. Double click it and give this variable a name. I call it ‘Platform’ because this variable will store the platform type. Now if you just enter ‘Platform’ into the name box and click out of the box, FileMaker will automatically enter a single dollar sign in front of it. This is FileMaker syntax for identifying a variable so that it can be used in calculations. If you enter a single dollar sign in front of you variable name this will be a local variable.
A local variable can only be used within this script. Once the script is complete, the local variable is deleted.
A global variable has two dollar signs in front of its name. A global variable can be used outside of this single script. So once the script is complete the variable is not deleted ( unless you specify a global variable in another script with the same name! ).
I actually make my platform variable global because I use it in other calculations and scripts throughout my solution. However this is entirely up to you.
Now to set the value for your variable!
The variable is built up of an If Statement, Get Function and a Choose Function.
Start – Do not copy this line
Get ( SystemPlatform ) = 4 ; “Web” ;
Get ( Device ) ;
“Desktop” ; // 0 – Unknown
“Desktop” ; // 1 – Mac
“Desktop” ; // 2 – PC
“Tablet” ; // 3 – Tablet
“Phone” // 4 – Phone
End – Do not copy this line
Leave the variables repetition set as 1.
Now that you have configured a variable that identifies your platform you can use it in If calculations to, for example, select a particular layout or perform certain steps!
I hope that you find this variable useful!Add to favorites