Detect Operating System

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Detect Operating System

Post by tegwin » Wed Dec 18, 2013 10:02 am

Hello,
I am looking to develop an app that will do something based on what system its runing on .. ie. if this is a Windows machine do this, or if Mac do soemthing else.. ALso like this can be installed on a Android but not iphone

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Detect Operating System

Post by Dixie » Wed Dec 18, 2013 10:06 am

read 'SystemVersion' in the dictionary....

tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Re: Detect Operating System

Post by tegwin » Wed Dec 18, 2013 10:42 am

Ok thanks.. does not really help as I dont know how to write code for it

thanks

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Detect Operating System

Post by Dixie » Wed Dec 18, 2013 11:03 am

for example...

Code: Select all

on openCard
   put the systemVersion into temp
   
   if temp = "10.9.0" then
      answer "This Mac is running 'Mavericks'"
   end if
end openCard

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Detect Operating System

Post by FourthWorld » Wed Dec 18, 2013 3:59 pm

The systemVersion will tell you the OS version number. To know which platform your app is running on see the platform function, e.g.:

Code: Select all

switch the platform
  case "MacOS" 
     DoMacStuff
     break
   case "Win32"
     DoWinStuff
     break
   case "Linux"
     DoLinuxStuff
     break
end switch
Ok thanks.. does not really help as I dont know how to write code for it
Sometimes the folks who help here in the forums will have the spare time to write example code for you, but many times they'll just help you identify the tokens needed - at that point you'll want to use the Dictionary included in LiveCode to learn about how the token works, see examples of its usage, and review the related "See Also" items.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9476
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Detect Operating System

Post by richmond62 » Wed Apr 22, 2020 7:56 am

"Win32" on any version of Windows
"Linux" on all Linux distributions
"MacOS" on any version of Mac OS X
"iphone" on iPhones, iPads and other iOS devices
"android" on smartphones, tablets and other Android devices
"HTML5" when running in a web browser

Well, Yes, But . . .

How does one differentiate between 32-bit and 64-bit variants of Windows?

How does one differentiate between 32-bit and 64-bit variants of Linux?

How does one differentiate between 32-bit and 64-bit variants of MacOS? [and before anyone makes a noise,
a pre-10.15 MacOS version while being 64-bit can run a 32-bit program].

MacOS 10.7.5 < 32 or 64-bit apps < MacOS 10.15.0

How does one detect that one is running a Windows standalone on WINE?

How does one detect ReactOS? [OK, OK, OK; I just bunged this one in to be snotty].

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Detect Operating System

Post by FourthWorld » Wed Apr 22, 2020 11:11 am

To distinguish processors use the processors function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Detect Operating System

Post by bogs » Wed Apr 22, 2020 11:22 am

I guess neither of you remember the thread that Richmond already brought this up in, where it was discovered that no variation of commands in Lc will tell you any of that, short of dropping to the shell (if available).
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Detect Operating System

Post by FourthWorld » Wed Apr 22, 2020 4:04 pm

I remember it well. I was as surprised as you were that this thread was necromanced with a question so thoroughly addressed so much more recently.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9476
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Detect Operating System

Post by richmond62 » Wed Apr 22, 2020 5:53 pm

so thoroughly addressed so much more recently
Is that a fact?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Detect Operating System

Post by FourthWorld » Wed Apr 22, 2020 6:36 pm

richmond62 wrote:
Wed Apr 22, 2020 5:53 pm
so thoroughly addressed so much more recently
Is that a fact?
Why do you imagine I might have both time and interest to mislead you in a way that would be so easily disproven with a quick search?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Detect Operating System

Post by FourthWorld » Wed Apr 22, 2020 6:42 pm

A search for "systemVersion" shows this thread as the first result, a conversation from Feb 21 through March 3, covering nearly every aspect of system profiling information included in LC, and many using external tools:
https://forums.livecode.com/viewtopic.php?f=6&t=33707

With a quick skim it looks like you posted half a dozen contributions to that four-page thread.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Detect Operating System

Post by bogs » Wed Apr 22, 2020 7:30 pm

Well, it was only 4 pages after all :P
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9476
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Detect Operating System

Post by richmond62 » Thu Apr 23, 2020 1:18 pm

I would not just suppose anyone on this list would want to mislead me: the word I took issue
with was "thoroughly" which is a highly subjective term.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Detect Operating System

Post by bogs » Thu Apr 23, 2020 2:18 pm

On the other side of that, the answer(s) given were pretty definitive, your not going to get that information from Lc, and the reasons why. You can, in desktop cases anyway, get the information by directly interrogating the OS, Lc just isn't going to build in a way to get it through the language.
Image

Post Reply

Return to “Talking LiveCode”