Le 04/02/2014 à 19:02, António Queirós < email@hidden> a écrit : Thank you all, four your kind answers. Our problem is not obtaining the result of display dialog. Our problems stays on the fact that when we export the script to an app, the message written between “…” doesn’t appear. If we run the script inside the editor everything is ok.
Thank you very much,
António Queirós
May you post a sample code ?
Here I use daily scripts saved as application with no problem related to display dialog.
Here is a sample which I use from time to time to check if AppleScript is behaving the normal way.
#=====
display dialog "blah blah" default answer "Is it raining ?"
set theAnswer to text returned of result
display dialog "You answered : " & theAnswer set p2d to path to desktop as text set destFile to p2d & "blahblah.txt" # save the answer on disk my writeto(destFile, theAnswer, text, true) # wait the end of the save process set oldSize to -1 delay 0.1 repeat try tell application "System Events" to set newSize to size of disk item destFile end try if newSize is not in {-1, oldSize} then exit repeat end repeat # clears the variable containing the text set theAnswer to "" # read the text file and append the date at its end set theAnswer to (read file destFile) & return & (current date) # pass the new text to the clipboard set the clipboard to theAnswer # change the variable's contents set theAnswer to "123" # grabs the clipboard's contents set theAnswer to the clipboard as text set dest_file to p2d & "blahblah2.txt" # wite it in a new text file my writeto(dest_file, theAnswer, text, false) # open the two text files tell application "TextEdit" open file destFile open file dest_file end tell delay 0.2 say "Paste the clipboard's contents were you want"
# When you are here, you know that everything behaved flawlessly
#===== (* *) on writeto(targetFile, theData, dataType, apendData) -- targetFile is the path to the file you want to write -- theData is the data you want in the file. -- dataType is the data type of theData and it can be text, list, record etc. -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it try set targetFile to targetFile as text set openFile to open for access file targetFile with write permission if not apendData then set eof of openFile to 0 write theData to openFile starting at eof as dataType close access openFile return true on error try close access file targetFile end try return false end try end writeto
#=====
Save it as an application and run it.
Yvan KOENIG (VALLAURIS, France) mardi 4 février 2014 21:45:38
|