Page 1 of 2

Determine the version number of the OS

Posted: Sat Jul 13, 2024 10:58 am
by Simon Knight
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?

Re: Determine the version number of the OS

Posted: Sat Jul 13, 2024 4:12 pm
by FourthWorld
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?

Re: Determine the version number of the OS

Posted: Sun Jul 14, 2024 5:33 pm
by Simon Knight
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.

Re: Determine the version number of the OS

Posted: Sun Jul 14, 2024 7:09 pm
by richmond62
Screenshot 2024-07-14 at 21.08.04.png
-
Nothing complex.

Re: Determine the version number of the OS

Posted: Sun Jul 14, 2024 7:23 pm
by Klaus
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)

Re: Determine the version number of the OS

Posted: Sun Jul 14, 2024 7:32 pm
by bn
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

Re: Determine the version number of the OS

Posted: Sun Jul 14, 2024 8:49 pm
by Simon Knight
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.

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 6:36 am
by richmond62
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 . . .

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 6:48 am
by Simon Knight
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

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 6:51 am
by Simon Knight
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

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 6:56 am
by richmond62
That all looks 'very jolly': I wish I knew where to find comprehensive documentation about LCB. :(

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 6:59 am
by Simon Knight
comprehensive documentation about LCB. :(
Ha!

This forum is probably the best you will find.

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 7:13 am
by Simon Knight
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

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 7:47 am
by richmond62
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 10110 times

Re: Determine the version number of the OS

Posted: Mon Jul 15, 2024 11:08 am
by bn
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