I’am getting a weird error with running the script using FastScripts that I don’t get using Applescript Script Editor.
The script I am using at forum.latenightsw
use scripting additions
use script "RegexAndStuffLib" version "1.0.7"
tell application "Safari" to tell the front document to set theText to do JavaScript "document.body.innerText"
set transaction_service_from to regex search once theText search pattern "Late (\\S.*)" replace template "$1"
Is this repeatable? Last I heard, there is an issue with AppleScript where this happens intermittently. You might want to contact Daniel at Red Sweater to find out the latest.
Thanks @ShaneStanley for the heads up about this thread. Yes, it’s an issue I’ve seen reported at least once before. I think it’s exacerbated by the new behavior in FastScripts 3 to run every script in its own process. Whatever the odds of this bug happening, I think it’s a situation where it is likely to happen earlier in the running time of a process.
If it is repeatable, it would be very helpful to try to do some debugging on the issue. Please drop me a line separately at support@redsweater.com so I can follow up with more debugging ideas. Thanks!
I am not sure what has happened but it went to normal after restarting my pc, so I have not faced that error anymore and will update this topic if this will happen again.
Nice that the problem went away, but frustrating to not be able to solve they why of it…
I ran this on my MacBook Air with Mojave with FastScripts 3.0b50 – no problems so far.
-Chris
AppleScript Code
--------------------------------------------------------
use scripting additions
use script "RegexAndStuffLib" version "1.0.7"
--------------------------------------------------------
set jsCmdStr to "document.body.innerText"
set theText to doJavaScriptInChrome(jsCmdStr)
set transaction_service_from to regex search once theText search pattern "Late (\\S.*)" replace template "$1"
tell application "FastScripts"
display message transaction_service_from ¬
dismissing after delay 4 ¬
at screen position top right
end tell
--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on doJavaScriptInChrome(jsCmdStr)
try
tell application "Google Chrome" to tell front window's active tab to execute javascript jsCmdStr
on error e
error "Error in handler doJavaScriptInChrome() of library NLb!" & return & return & e
end try
end doJavaScriptInChrome
--------------------------------------------------------
I have exactly the same problem, so the bug is still there!
I have 2 scripts with identical structure but some differences inside the handlers.
They don’t explicitly use ASObjC but they have:
use script "RegexAndStuffLib" version "1.0.7"
which in turn uses ASObjC, and thereby framework Foundation.
The trouble occurs for the command
regex search allText search pattern "..." capture groups {1}
Error message is:
NSRegularExpression doesn’t understand the “regularExpressionWithPattern_options_error_” message.
It only occurs for one of the two almost identical scripts, and only when run under FastScripts, whereas it runs perfectly ok in Script Debugger!?
It is consistent and repeatable, except that in rare occasions the troublesome script can actually work on one single run but then it fails all other runs! The “good” script always seem to work.
It makes no difference if I add:
use framework "Foundation" --for ASObjC
I use macOS 13.2.1
FastScripts 3.2.5
Computer is restarted.
A test:
If I remove 3 small properties from the header, then it increases the chance of the script to run that regex search command (but the rest of the script will of course not work if I thus destroy parts of it).
I’d like to bump this topic since I get no response, and I certainly don’t think I am the only one with this problem. I first intended to start a new thread with a different title, but I discovered that the issue had already been brought up earlier, albeit with no definite solution.
Just for the hell of it, I tried the plist entry as suggested in that thread, despite Shane says it should be meaningless and obsolete since many years!
So I entered:
And, lo and behold, it does eliminate the problem!
I revert, i.e delete. the key, and the problem occurs again!
Since overall it feels a bit erratic, I do not fully trust this as the real solution, but rather as a symptom or reagent or crutch. Or maybe it is the solution? Or maybe it is related to same race condition that is script dependent?
I was going to recommend trying the OSAAppleScriptObjCEnabled trick since it seemed to work for the Dialogs Toolkit scenario. I’m glad it seems to work, but also appreciate that it’s not super-convincing it won’t come back. But in the absence of more definitive explanations I think we might need to just go with the workaround for now and hope it does the trick. If anybody does run into the problem with the property list key enabled, it would be good to know about.