• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problem with display dialog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with display dialog


  • Subject: Re: problem with display dialog
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 04 Feb 2014 21:45:44 +0100


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

#=====
(*
Handler borrowed to Regulus6633 - http://macscripter.net/viewtopic.php?id=36861
*)
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



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >problem with display dialog (From: António Queirós <email@hidden>)

  • Prev by Date: Re: problem using display dialog in mavericks
  • Next by Date: Re: AppleScript-Users Digest, Vol 11, Issue 37
  • Previous by thread: problem with display dialog
  • Next by thread: display dialog problem exporting to app
  • Index(es):
    • Date
    • Thread