Display Dialog

Hello,

Can a display dialog hold the last entry as default answer?

A dialog can use the reply of a previous dialog as default answer, yes.

But you cannot update the current dialog; you must close it, and use the response in a second dialog.

set reply to text returned of (display dialog "Enter your name" default answer "")

display dialog "Your name is" default answer reply

You can use a property which is an persisten global/object property value. The previous answer will be shown between runs until you recompile the script.

property theAnswer : ""

set theAnswer to text returned of (display dialog "Enter your name" default answer theAnswer)

Hello Bazzie,

Thanks for your example, but in my script it doesn’t work. see below

property theAnswer : “”

– vb default answer: 2x2x20

set aantal_rijen to text returned of ¬
(display dialog “Dupliceren!” default answer theAnswer)

set ab to (current date) as string
set teller to 1
set p to 2.834645669

set AppleScript’s text item delimiters to “x”
set aantal_rijen_items to text items of aantal_rijen
set aantal_B to text item 1 of aantal_rijen_items
set aantal_H to text item 2 of aantal_rijen_items
try
set aantal_tussenruimte to text item 3 of aantal_rijen_items
on error
set aantal_tussenruimte to 20
end try

set AppleScript’s text item delimiters to “”

tell application “Adobe Illustrator”
tell current document
set aritem to selection
set aantalitems to count aritem
set i to item 1 of aritem
set note of i to ab
copy geometric bounds of i to {x1, y1, x2, y2}
set breedte to get width of i
set hoogte to get height of i
–set selected of i to false
end tell

repeat (aantal_H - 1) times
	
	
	
	
	
	
	tell current document
		
		set y1 to y1 + hoogte + (p * aantal_tussenruimte)
		duplicate i with properties {position:{x1, y1}, note:ab}
	end tell
	
end repeat





tell current document
	
	set nieuwe_groep to make new group item
	move (every page item whose note is ab) to nieuwe_groep
	repeat (aantal_B - 1) times
		
		set x1 to x1 + breedte + (p * aantal_tussenruimte)
		set Z to duplicate nieuwe_groep with properties {position:{x1, y1}}
	end repeat
	set selected of (every page item whose note is ab) to true
	activate
	tell application "System Events"
		
		keystroke "g" using command down & shift down
	end tell
	try
		set selected of selection to false
	end try
end tell

end tell

Variable theAnswer should be aantal_rijen :slight_smile:

property aantal_rijen : "2x2x20"


-- vb default answer: 2x2x20

set aantal_rijen to text returned of ¬
    (display dialog "Dupliceren!" default answer aantal_rijen)

set ab to (current date) as string
set teller to 1
set p to 2.834645669




set AppleScript's text item delimiters to "x"
set aantal_rijen_items to text items of aantal_rijen
set aantal_B to text item 1 of aantal_rijen_items
set aantal_H to text item 2 of aantal_rijen_items
try
    set aantal_tussenruimte to text item 3 of aantal_rijen_items
on error
    set aantal_tussenruimte to 20
end try

set AppleScript's text item delimiters to ""




tell application "Adobe Illustrator"
    tell current document
        set aritem to selection
        set aantalitems to count aritem
        set i to item 1 of aritem
        set note of i to ab
        copy geometric bounds of i to {x1, y1, x2, y2}
        set breedte to get width of i
        set hoogte to get height of i
        --set selected of i to false
    end tell
   
    repeat (aantal_H - 1) times
       
       
       
       
       
       
        tell current document
           
            set y1 to y1 + hoogte + (p * aantal_tussenruimte)
            duplicate i with properties {position:{x1, y1}, note:ab}
        end tell
       
    end repeat
   
   
   
   
   
    tell current document
       
        set nieuwe_groep to make new group item
        move (every page item whose note is ab) to nieuwe_groep
        repeat (aantal_B - 1) times
           
            set x1 to x1 + breedte + (p * aantal_tussenruimte)
            set Z to duplicate nieuwe_groep with properties {position:{x1, y1}}
        end repeat
        set selected of (every page item whose note is ab) to true
        activate
        tell application "System Events"
           
            keystroke "g" using command down & shift down
        end tell
        try
            set selected of selection to false
        end try
    end tell
   
end tell

yes!!

Bazzie, Thanks a lot.

As there’s only one display dialog statement in your code and you want to keep the most recent answer consider this:

To keep a property reliability persistent when running the script multiple times, you have to save the script as application or save the property externally for example in a script object or plist/text file.