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.
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.
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?
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
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.
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.
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.
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.lcb23: error: Parsing error: syntax error
put the systemversion into tOSno
^
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.lcb23: error: Parsing error: syntax error
get the systemversion
^
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.
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:
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