Determine the version number of the OS

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Determine the version number of the OS

Post by Simon Knight » Sat Jul 13, 2024 10:58 am

Hi,
Is there a way that code in a Livecode Builder (LCB) handler can determine the version number of the parent operating system. In Livecode Script this can be read using a shell command e.g.

Code: Select all

function MacOSVersion
   put "sw_vers"  into tCommand
   put shell(tCommand) into tResult
   put line 2 of tResult into tOSVersion
   put the last word of tOSVersion into tOSVersion
   return tOSVersion
end MacOSVersion
Unfortunately I can not find a way of achieving the same result in LCB. Any ideas?
best wishes
Skids

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Determine the version number of the OS

Post by FourthWorld » Sat Jul 13, 2024 4:12 pm

LC Script has the systemVersion function. I haven't had a need to play with Builder yet, but I would imagine there's a way to make callbacks to LC Script, no?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Sun Jul 14, 2024 5:33 pm

Hi Richard,
I've had a search and can not discover a way of calling the function. There is the post call but that calls a handler and does not seem to get a return value.

I could try an ObjectiveC FFI function but that adds complexity.
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10084
Joined: Fri Feb 19, 2010 10:17 am

Re: Determine the version number of the OS

Post by richmond62 » Sun Jul 14, 2024 7:09 pm

Screenshot 2024-07-14 at 21.08.04.png
-
Nothing complex.
Attachments
System Guff.livecode.zip
Stack.
(955 Bytes) Downloaded 664 times

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Determine the version number of the OS

Post by Klaus » Sun Jul 14, 2024 7:23 pm

richmond62 wrote:
Sun Jul 14, 2024 7:09 pm
Screenshot 2024-07-14 at 21.08.04.png
-
Nothing complex.
You missed the forum name: Livecode Builder not Livecode Script! 8)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Determine the version number of the OS

Post by bn » Sun Jul 14, 2024 7:32 pm

Hi Simon,

If I understand what you want to do you could have a look at

"execute Script" in LCB
It lets you execute a LCS script from within LCB

Kind regards
Bernd

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Sun Jul 14, 2024 8:49 pm

Thanks for your inputs.

I am trying to simplify the interface that is employed by my extension. At the moment the calling LCS has to pass in the version number of the OS that is being run. This could be either an iOS or MacOS version number. LCB does provide a function that returns the environment but not one that returns the version of the OS. I would prefer to remove this requirement.

Its looking like I will have to try reading the information using ObjectiveC which complicates matters.
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10084
Joined: Fri Feb 19, 2010 10:17 am

Re: Determine the version number of the OS

Post by richmond62 » Mon Jul 15, 2024 6:36 am

You missed the forum name: Livecode Builder not Livecode Script!
No, I didn't: what I DID do was work on the (possibly mistaken) idea that as LiveCode and LCB 'interpenetrate' each other to a certain extent you could leverage LCS for things that were not so easy to manage in LCB.

Reading here: https://livecode.com/topic/livecode-bui ... reference/

I get the impression that LCB is related to LCS:

"LiveCode Builder is a variant of the current LiveCode scripting language"

and that LCB is to be used to build 'extensions' to LCS . . .

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Mon Jul 15, 2024 6:48 am

Alas if only it were that simple.
6:46 AM: Compiling module /Users/skids/Programming/LiveCode/LivecodeBuilder_Projects/EventKit/Version_1-14-58-1 attempt to add OS switching/ReadCalendarEvents.lcb
6:46 AM: Error: on line 1043 ():
6:46 AM: Error: /Users/skids/Programming/LiveCode/LivecodeBuilder_Projects/EventKit/Version_1-14-58-1 attempt to add OS switching/ReadCalendarEvents.lcb:1043:23: error: Parsing error: syntax error
put the systemversion into tOSno
^

6:46 AM: Error: failed to compile module
6:46 AM: Loaded library
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Mon Jul 15, 2024 6:51 am

and with alternative syntax:
6:50 AM: Compiling module /Users/skids/Programming/LiveCode/LivecodeBuilder_Projects/EventKit/Version_1-14-58-1 attempt to add OS switching/ReadCalendarEvents.lcb
6:50 AM: Error: on line 1043 ():
6:50 AM: Error: /Users/skids/Programming/LiveCode/LivecodeBuilder_Projects/EventKit/Version_1-14-58-1 attempt to add OS switching/ReadCalendarEvents.lcb:1043:23: error: Parsing error: syntax error
get the systemversion
^

6:50 AM: Error: failed to compile module
6:50 AM: Unloading community.livecode.skids.readcalendarevents
6:50 AM: Loaded library
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10084
Joined: Fri Feb 19, 2010 10:17 am

Re: Determine the version number of the OS

Post by richmond62 » Mon Jul 15, 2024 6:56 am

That all looks 'very jolly': I wish I knew where to find comprehensive documentation about LCB. :(

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Mon Jul 15, 2024 6:59 am

comprehensive documentation about LCB. :(
Ha!

This forum is probably the best you will find.
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Determine the version number of the OS

Post by Simon Knight » Mon Jul 15, 2024 7:13 am

Richmond,

Thanks for your stack : I had missed the built in function so had made a call to the shell to read the system version. Now the call to my library can use a single line which meets my objective.

Code: Select all

put calLibraryVersion(the systemversion) into tResult
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10084
Joined: Fri Feb 19, 2010 10:17 am

Re: Determine the version number of the OS

Post by richmond62 » Mon Jul 15, 2024 7:47 am

And with any luck, if you are using a commercial, post-963 version of LiveCode you will not get daft numbers such as 10.16.0 for MacOS 12 . . . 8)

In another universe:
-
Screenshot 2024-07-15 at 12.43.08.png
Screenshot 2024-07-15 at 12.43.08.png (48.11 KiB) Viewed 10106 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Determine the version number of the OS

Post by bn » Mon Jul 15, 2024 11:08 am

Simon Knight wrote:
Sat Jul 13, 2024 10:58 am
Hi,
Is there a way that code in a Livecode Builder (LCB) handler can determine the version number of the parent operating system. In Livecode Script this can be read using a shell command e.g.
Unfortunately I can not find a way of achieving the same result in LCB. Any ideas?
Hi Simon,

here is a snippet for LCB to get the system version using execute script:

Note this is LCB syntax

Code: Select all

public handler OnMouseUp()
	GetSystemVersion()
end handler

private handler GetSystemVersion()
	variable tSystemversion as String
	log "i was called"
	execute script "return the systemVersion"
	put the result into tSystemversion
	execute script "answer the systemversion"

end handler
I trigger it using OnMouseUp(), of course you would do the trigger differently in your project

Kind regards
Bernd

Kind regards
Bernd

Post Reply