Page 1 of 1
Reading Characters from a string
Posted: Sat Jul 13, 2024 11:15 am
by Simon Knight
I am attempting to read the first three characters of a string inside a library extension written in Livecode Builder. My test handler is below and I have tried various different versions without luck.
Code: Select all
public handler calLibraryVersion() returns String
variable tOsSystem as String
variable tTest as String
put the operating system into tOsSystem -- "mac of Calendar Library"
get char 1 to 3 of tOsSystem
put the result into tTest
return "Library version 1.14.58-7 on OS : " & tTest
end handler
The dictionary entry for RangeCharOf contains this code snip:
Code: Select all
get char 5 to 10 of tString // Evaluates chars 5 to 10
My handler runs but returns the full version of tOsSystem.
What have I missed?
Re: Reading Characters from a string
Posted: Sat Jul 13, 2024 4:04 pm
by lcwill
(I'm assuming you are on mac)
Ignore extra "\" on the strings with "."
The expected result for your handler would be:
"Library version 1\.14\.58-7 on OS : mac"
(Taken from the Dictionary)
Returns a string describing the operating system that LiveCode is running on. The possible values are:
"windows" - 32-bit and 64-bit Windows
"mac" - Desktop OS X
"ios" - iOS (iPhone and iPad)
"android" - Android Linux devices
"linux" - All other Linux platforms
If you are getting a result different from the above could you specify Engine version and OS?
Code: Select all
public handler calLibraryVersion() returns String
variable tOsSystem as String
variable tTest as String
/* If running on macOS you are putting "mac" inside tOsSystem */
put the operating system into tOsSystem
/* You could also directly do here:
* put char 1 to 3 of tOsSystem into tTest
*/
get char 1 to 3 of tOsSystem
put the result into tTest
/* You could also directly do like:
* return "Library version 1\.14\.58-7 on OS : " & char 1 to 3 of tOsSystem
*/
return "Library version 1\.14\.58-7 on OS : " & tTest
end handler
A simplified version of the handler could be:
Code: Select all
public handler calLibraryVersion() returns String
return "Library version 1\.14\.58-7 on OS : " & char 1 to 3 of the operating system
end handler
PD: ignore extra "\" on the string "Library version 1\.14\.58-7 on OS : "
Re: Reading Characters from a string
Posted: Sun Jul 14, 2024 2:52 pm
by Simon Knight
Thanks for your code. I have created an extension just to test the command 'the operating system' and it is working as expected. I need to try and discover why I was seeing erroneous results. Yes I am using a mac and I was using a version of Livecode IDE where I had tried to update the code signing because I had modified the Info.plist file.
Re: Reading Characters from a string
Posted: Sun Jul 14, 2024 3:03 pm
by Simon Knight
Should have said :
I'm using Mac OS 14.5 Sonoma
Livecode 9.6.12
The edits to the Info.plist file were i.a.w. instructions in bug report 24054
https://quality.livecode.com/show_bug.cgi?id=24054
So could you add this line in the plist - just below the one for "NSCalendarsUsageDescription":
<key>NSCalendarsFullAccessUsageDescription</key>
<string>LiveCode requires permission to access your Calendars</string>
Note: There are 2 plist files where you have to try this change:
/Applications/LiveCode <version>.app/Contents/Info.plist -> This is for granting access to the LiveCode IDE
/Applications/LiveCode <version>.app/Contents/Tools/Runtime/Mac OS X/x86-64/Standalone.app/Contents/Info.plist --> This is for the standalone
and then run the following Terminal command :
codesign --force --deep -s - /path_to_LiveCode.app
It appears that while the Terminal command solved the problem that I was reporting it is likely that if fails to correctly code sign all the components which could be leading to odd faults.
Given the issues I have seen I decided to pause the work I was doing and wait until RunRev update the Info.plist file in a properly signed build of the Livecode IDE.