why does this work in script editior but not in applescript studio

display dialog "Would you like to purchase the full version?" with title "Demo Version" buttons {"Yes", "No"} default button {"Yes"}

for some reason it won’t compile for me in applescript studio with the

with title "Demo Version"

I was also not able to use the

cancel button

but the rest works fine. Why is this am I doing something wrong.

Brian

Gidday bmbingham

I couldnt get he “Cancel” button to return anything either, some body here will no why, but as for the rest of it try the below

on awake from nib theObject
tell application “Finder”
activate
set _Name to display dialog “Would you like to purchase the full version?” with title “Demo Version” buttons {“Yes”, “No”, “Cancel”} default button {“Yes”}
if button returned of _Name is “Yes” then
say “gidday” using “Vicki”
end if
end tell
end awake from nib

Budgie

Hi,

Just a thought… I suppose that “Cancel” is some kind of a reserved error word for when the user wants to get out of the script. I also tried it several times in Script Editor and it does not return anything. So, you are both right there.

However, you can actually get something out of clicking the “Cancel” button by inserting your codes inside a try block and trapping the error that results from clicking the button.

Try the codes below in Script Editor:


try
	display dialog "Would you like to purchase the full version?" with title "Demo Version" buttons {"Yes", "No", "Cancel"} default button {"Yes"}
	
on error the error_message number the error_number
	display dialog "Error: " & the error_number & ". " & the error_message buttons {"Cancel"} default button 1
end try

When you do this, you will get a resulting dialog that says “Error:-128. User cancelled.”

So, it is not inert and not just there for nothing.

archseed :slight_smile:

Hi,

display dialog in AppleScript Studio is not the same as in the Standard Scripting Additions

this is the AppleScript Studio version:

display dialog reference ¬
attached to window ¬
buttons list ¬
default answer unicode text ¬
default button anything ¬
giving up after integer ¬
with icon anything

and this the version of the Standard Scripting Additions

set theResult to display dialog string ¬
default answer string ¬
hidden answer boolean ¬
buttons {string, …} ¬
default button number | string ¬
cancel button number | string ¬
with title string ¬
with icon number | string ¬
with icon with icon ¬
with icon file ¬
giving up after integer

where did you go to see the applescript studio version?

In the documentation of AppleScript Studio or to see the dictionary directly
click AppleScriptKit.sdef in your Xcode project

Thanks

That should help quite a bit I felt like I was flying blind.