I’m pretty new to scripting; I’m trying to figure out dialogs using Smile (I don’t think my script is complicated enough to warrent figuring out Applescript Studio at this point). I have created a dialog that is ok as far as I know, but I don’t know how to successfully call it. I have
DisplayDlog("", Path:"DL Get Text")
--code using text input
I am trying to accomplish the same thing as
display dialog "Enter the text" default answer ""
set theText to the text returned of result
The dialog “DL Get Text” has a text field with id 2; what command(s) do I use (in the calling script and/or in the script for the dialog) to get the data from the dialog into the calling script?
Thanks for the response. I just figured out one problem: I have to name the dialog the same in the dialog script as in the calling script: “DL Get Text” in my example (this is the basic level I’m working at). Now my problem is after the dialog is called the subsequent lines of code in the calling script are executed without waiting for the dialog to be responded to and dismissed; i.e. the dialog is displayed then the rest of the script is executed. This is the dialog script:
property theText : "enter the text here"
on prepare theDialog
set name of theDialog to "DL Get Text"
--dialog item 2 is a text box
set contents of dialog item 2 of theDialog to theText
end prepare
on click in theDialog item number i
-- item 4 is the OK button
if i is 4 then
set theText to contents of dialog item 2 of theDialog
delete theDialog
end if
end click in
when the dialog is called from the calling script with
DisplayDlog("", Path:"DL Get Text")
set inputText to contained data of dialog item 2 of dialog "DL Get Text"
inputText is immediatly set to “enter the text here” and the script continues executing while the dialog is being displayed. How do I tell the calling script to wait until the dialog is dismissed before continuing with execution? And/or do I need to add something to the code of the dialog?
set f to alias "HD:Users:me:Desktop:compiled dialog"
set w to make new basic object with properties {path name:f}
repeat
smilepause 0.1
set contents_of_text_field to x of script of w
if contents_of_text_field is not false then
delete w
exit repeat
end if
end repeat
contents_of_text_field --> latest value of text field when user pressed "ok" or "submit" or whatever button with the attached script
Good stuff: many thanks. I didn’t imagine it would be that difficult to create a simple ‘constrained’ dialog–makes me wonder if I shouldn’t be using Applescript Studio after all. . .
In this particular situation, supossing you’re going only to retrieve data only from a text field, I’d use standard additions’ “display dialog”
set input_text to text returned of (display dialog "something" default answer "some text")
But I like so much Smile’s environment and, if Satimage people continues this wild development with GUI stuff, it will be much more powerful than Studio! :rolleyes: