Book Image

LiveCode Mobile Development Cookbook

By : Dr. Edward Lavieri
Book Image

LiveCode Mobile Development Cookbook

By: Dr. Edward Lavieri

Overview of this book

Table of Contents (17 chapters)
LiveCode Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Detecting the operating system


In this recipe, you will learn how to determine what operating system your user has installed on their device.

How to do it...

Perform the following steps to detect the installed operating system:

  1. Open LiveCode and create a new main stack.

  2. Add the following code to the stack's card:

    on preOpenCard
      local tPlatform, tVersion
      
      put the platform into tPlatform
      put the systemVersion into tVersion
      
      answer tPlatform & tab & tVersion titled "Your OS"
    end preOpenCard
  3. Test your application in the simulator or on an actual device. See the following screenshot for a sample result:

How it works...

In this recipe, we used two functions to determine the user's device platform and operating system version. The first function, platform, will return either iphone or android, depending on the mobile device being used. The second function, systemVersion, returns the numeric and decimal (that is 7.0.1) version of the user's OS.