Charles Calthrop Posted June 14, 2012 Posted June 14, 2012 I have a script that goes through text records in a database and then triggers a remote script that speaks the text and then another script that updates the Date Last Read field. If I press ESC in the middle of the Speak script and thus abort it, it currently still updates the Date Last Read field, even though the whole text hasn't been read. I'd like it to only update the Date Last Read field if the whole text has been read. I assumed that it would be possible to monitor the Speak script result using get(scriptresult) in the main script but this doesn't appear to work. Get(lasterror) directly after the Speak script also doesn't appear to register an error. I then thought that if I set a successful running of the Speak script to exit with a positive value 'script_successful' that I'd be able to track if that value wasn't sent and thus conclude that the script had been aborted. Even if I abort the Speak script in the middle, it still seems to send the value 'script_successful' as the result of the Exit Script step at the very end of the script. I'm a bit confused! Any help would be greatly appreciated. Many thanks.
Vaughan Posted June 14, 2012 Posted June 14, 2012 You need to find out whether the Speak script step can be trapped for errors. Create a script that does this: Set Error Capture [ on ] Speak Text [ <lots of text> ] Set variable [ $error ; Get( LastError ) ] Show Custom Dialog [ $error ] The custom dialog is set to display the $error variable as the dialog message text. Run this with a lot of text to speak, then cancel the speech before it's finished and make not of the error that is returned in the dialog. Best case is the dialog indicates "1" is returned, which is user cancelled action. In fact any other result apart from zero would be workable. Worst case is "0" (zero) is returned. This would mean that FileMaker has passed the reading of the text to the operating system, and the cancellation has not occurred in FMP itself. It only knows that the passing-to-the-OS part went without error. If that is the case then you might want to change to using AppleScript to read the text instead, you might be able to capture the error code and return it all in the AppleScript. Somebody else will need to help with the AppleScript code to do this, it's not my area of expertise. :D
Charles Calthrop Posted June 14, 2012 Author Posted June 14, 2012 Vaughan, Thanks for that, I now have a working script! It seems that when ESC is pressed during the Speak part of a script it doesn't abort the whole script but instead just the Speak step which is unexpected. As a result the get(lasterror) placed just after the Speak step as you suggest worked a treat and returns a 1. Many thanks for your fast and helpful response!
Vaughan Posted June 14, 2012 Posted June 14, 2012 It seems that when ESC is pressed during the Speak part of a script it doesn't abort the whole script but instead just the Speak step which is unexpected. It might not be what YOU expected, but that's how FMP works. Read up on the Allow User Abort script step.
Recommended Posts
This topic is 4545 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now