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.
I'm trying to write a url parsing library and I'm stuck on regex. I didn't see any built in regex in LiveCode Builder so I tried to use execute script. The code I'm trying is below. The problem is I can't get anything meaningful returned from execute script If I try to return a string from the function and return tMatches["host"] then I get nothing. Ideally I'm trying to return tMatches as an array for further processing. The LiveCode Script does work in the normal IDE.
variable tRegex as string
put "(?#scheme)(?:^([a-zA-Z][a-zA-Z0-9\\+\\.-]*)://)?(?#username-pasword)(?:([^/:]+[:@])?([^/:]+)@)?([^/:]*)?(?#port)(:[0-9]*[^/])*(?#path)(/[^?]*)*(?#query)(\\?[^#]*)*(?#fragment)(#.*)*" into tRegex
variable tScript as string
variable tMatches as array
put "get matchText(pURL, tRegex, rScheme, rUsername, rPassword, rHost, rPort, rPath, rQueryString, rFragment);" into tScript
put "put rScheme into tA[\qscheme\q];put rUsername into tA[\qusername\q];put rPassword into tA[\qpassword\q];" after tScript
put "put rHost into tA[\qhost\q];put rPort into tA[\qport\q];put rPath into tA[\qpath\q];" after tScript
put "put rQueryString into tA[\qquery string\q];put rFragment into tA[\qfragment\q];return tA" after tScript
-- Use 'execute script' for access to regular expressions.
execute script tScript
put the result into tMatches
Yes, at the moment there is no regex support in LiveCode builder. This is certainly something we'll be adding.
In the mean time, your execute script method is a work around. We discovered that arrays are not being passed between LCS and LCB currently in alpha 2. Mark has applied a fix though if you are building direct through xCode. I'm not sure if it's been through code review yet so it may not have been merged into the main widgets branch yet. Feel free to pull it and test it though.
Just as a followup, our intention is to wrap the pcre library once the foreign code interface is mature enough. There are a variety of other features we'll implement by wrapping libraries which are waiting on that FFI feature.
Just as a followup, our intention is to wrap the pcre library once the foreign code interface is mature enough. There are a variety of other features we'll implement by wrapping libraries which are waiting on that FFI feature.
Thanks for the info Ben. I tried compiling the develop branch with Mark's fix applied in Xcode 6.1.1 on 10.9 but I'm having trouble with lc-bootstrap-compile.
Undefined symbols for architecture i386:
"___exp10", referenced from:
_uprv_pow10_52 in libfoundation.a(putil.ao)
I'm trying to track down the cause but if anyone has any ideas, please let me know.
@trevordevore: I've not seen that issue before - try doing a 'Clean' and rebuilding (in case it is stale code) and check the SDK version being compiled against is 10.8.
@trevordevore: @runrevian has the same setup as you (6.1.1 and 10.9) but seems to be compiling it fine - however, I've asked him to check out a completely fresh livecode repo and submodules and rebuild develop from scratch to see if he sees the same issue.
Thanks for testing @livecodeian. I just tried reinstalling Xcode but still no luck. Should any changes need to be made to the base Xcode install with the development branch? We don't need the Xcode 3 stuff installed as per the instructions I made when the engine was first posted on github, do we?
I was puzzled by 'putil.ao' as there is no file like that in libfoundation *but* I'd forgotten that libfoundation is linked with ICU and libffi so that things depending on it don't have to. So - I think the problem is that you need to update your mac libs...
cd prebuilt
sh fetch-libraries.sh
This should update your local copies (in particular for Mac) and then hopefully things will be happy!
The only change I had to make was to pass in 'mac' as a param to fetch-libraries.sh
sh fetch-libraries.sh mac
Otherwise I got this output and building wouldn't work:
mac linux win32 android ios
fetch-libraries.sh: line 73: ${ARCHS_mac linux win32 android ios[@]}: bad substitution
fetch-libraries.sh: line 74: ${LIBS_mac linux win32 android ios[@]}: bad substitution
fetch-libraries.sh: line 75: ${SUBPLATFORMS_mac linux win32 android ios[@]}: bad substitution
Fetching library: OpenSSL-1.0.1g-All-Universal-Headers
Extracting library: OpenSSL-1.0.1g-All-Universal-Headers
Fetching library: ICU-52.1-All-Universal-Headers
Extracting library: ICU-52.1-All-Universal-Headers
trevordevore wrote:The only change I had to make was to pass in 'mac' as a param to fetch-libraries.sh
sh fetch-libraries.sh mac
Otherwise I got this output and building wouldn't work:
mac linux win32 android ios
fetch-libraries.sh: line 73: ${ARCHS_mac linux win32 android ios[@]}: bad substitution
fetch-libraries.sh: line 74: ${LIBS_mac linux win32 android ios[@]}: bad substitution
fetch-libraries.sh: line 75: ${SUBPLATFORMS_mac linux win32 android ios[@]}: bad substitution