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

Re: Determine the version number of the OS

Post by Simon Knight » Mon Jul 15, 2024 2:23 pm

Bernd,

Brilliant! Thanks yet again. How did you get from the dictionary entry to your script. I looked and could not see a way of getting a return value back into LCB.

Here is my version of your script that returns a "Number" to the calling handler. ( I tied my self in knots with extracting and changing the variable type from string to number)

Code: Select all

  private handler GetSystemVersion() returns Number
	variable tSystemversion as String
	variable tListOfString as List
	variable tListOfNum as List
	variable tOsVerNo as Number
	log "GetSystemVersion was called"
	execute script "return the systemVersion"
	put the result into tSystemversion
	log "tSystemversion is a string : " & tSystemversion
	split tSystemversion by "." into tListOfString
	log "tSystemversion is a list of strings : "
	log tListOfString
	--execute script "answer the systemversion"
	put tListOfString parsed as list of number into tListOfNum
	log "tListOfNum is a list of numbers : " 
	log tListOfNum
	put element 1 of tListOfNum into tOsVerNo

	log "Variable tOsVerNo is now set to number : " & tOsVerNo formatted as string
	
	return tOsVerNo
end handler
best wishes
Simon
best wishes
Skids

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 4:56 pm

Simon Knight wrote:
Mon Jul 15, 2024 2:23 pm
Bernd,
How did you get from the dictionary entry to your script. I looked and could not see a way of getting a return value back into LCB.
Hi Simon,

one way is to use the stack I posted here

viewtopic.php?f=93&t=39213&p=230810&sid ... 8c#p230816

and search for "execute script". You will find at least 2 examples from
Treeview widget
GradientrampEditor widget

Actuall I had a need to get at the abbr system weekdaynames and the abbr system monthNames for a calendar widget.

Code: Select all

private handler getMonthAndDayNames() returns nothing
   if mMonthAndDayNamesType is "System" then
      variable tDayNames as String
      execute script "return the abbr system weekdaynames"
      put the result into tDayNames
      replace "." with "" in tDayNames
      replace newline with "," in tDayNames
      split tDayNames by "," into mDayNames

      variable tMonthNames as String
      execute script "return the abbr system monthNames"
      put the result into tMonthNames
      replace "." with "" in tMonthNames
      replace newline with "," in tMonthNames
      split tMonthNames by "," into mMonthNames
   end if
That is how I did it.

Please note that in the version of "tinyDictionary" I posted next to the referenced post for stack "FindTextInLCB" is updated.
I made a mistake that makes it fail to show the LCB dict of a .lcb file when selecting a .lcb file (could not be selected). This is now fixed and I also uploaded this version to "LivecodeShare" and "Sample Stacks" accessible from within the IDE.

KInd regards
Bernd

Post Reply