Alain Pastor wrote: > > > Steve Crossman wrote: > >> I am having some problems with the sample AppleScript code in Release >> 7 examples by Alain, date 9-5-02 >> I am running the latest beta 11. >> In the AppleScript other tests, selecting the conditional dialog menu >> example and clicking cancel will not allow any further scripts to run. >> The following error is displayed : A identifier can't go after this >> identifier. >> >> Also, when receiving a message reply in the TEhandle, I want to parse >> the reply but I am not able too or I am getting strange results. >> Anyone have a snippet of code that will allow me to step through it >> and pull characters out of the handle. The reply of course in not >> limited to 255 byte lengths but could be up to 32767 characters long. >> > > I can confirm the behavior, but I have no fix at the moment and I don't > see why this is happening :-( > Steve, I'll answer publicly to your private email because that might interest others. I have finally found where was the problem. The AppleScript routines work in an unusual way when an error is encountered. err = USR AppleScriptRun( message ) When an error occurs, you get an AppleScript error message in the message string variable and you can possibly have OS errors returned in err. In addition AppleScript can return a more human friendly error message supposed to give more clue about the error encountered. It has been requested that this message in its entirety was also sent back to the caller routine, but where is the room to store that lengthy error message? It is simply in the buffer waiting to be extracted, therefore if you want to run a new script after an error forgetting to clean the buffer, the AppleScript routine will attempt to compile and run a script consisting in an error message followed by your new script. This is the technical explanation. The solution is simple: whether you've got an error or not, you need to empty the buffer with AppleScriptGetResult. The example on the CD was faulty and should have been written like this: err = usr AppleScriptRun( message ) resultH = usr AppleScriptGetResult long if resultH call TESetText([resultH],fn GetHandleSize( resultH ), tehandle( 1 )) call DisposeHandle( resultH ) cls print "Choose a script under the Script menu" xelse edit$( 1 ) = message end if Here is a generic scenario: // run the script err = Usr AppleScriptRun( message ) // extract the result in all conditions resultH = Usr AppleScriptGetResult Select err Case _noErr // deal here with a valid result in resultH Case Else Long If resultH // deal here with the long error message in resultH Xelse // deal with possible short error message in message // or the value of the err variable End If End Select // clean up memory if need be If resultH Then Call DisposeHandle( resultH ) Alain