property add2yr : missing value
display dialog "enter year adjustment:" default answer add2yr buttons {"skip", "set"} default button 1
copy the result as list to {text_returned, button_pressed}
log text_returned
log button_pressed
if button_pressed is "set" then
set add2yr to text_returned as integer
else
set add2yr to missing value
end if
log add2yr
in 10.6.8:
are now borked in 10.9:
seems that properties are now read-only:-( w-t-f, apple?
Serves you right for coercing a record to a list and expecting the result to have a particular order!
property add2yr : missing value
display dialog "enter year adjustment:" default answer add2yr buttons {"skip", "set"} default button 1
set {text returned:text_returned, button returned:button_pressed} to result -- Set your variables directly from the record properties.
log text_returned
log button_pressed
if button_pressed is "set" then
set add2yr to text_returned as integer
else
set add2yr to missing value
end if
log add2yr
Here is another way of doing it, which may appear clearer, or not, where you use the properties of the display dialog’s result directly from within a tell block.
property add2yr : missing value
tell (display dialog "enter year adjustment:" default answer add2yr buttons {"skip", "set"} default button 1)
if button returned is "set" then
set text_returned to text returned
if text_returned is "" or text_returned is ¬
"msng" then set text_returned to "0"
set add2yr to text_returned as integer
else
set add2yr to missing value
end if
tell me to log add2yr
end tell
For years we were said that assuming that values embedded in a record are matching a pattern.
Some users tookcare of that.
It’s what does Nigel Garvey.
An other way was :
set the_result to display dialog "azerty" default answer "qwerty"
set button_returned to button returned of the_result
set text_returned to text returned of the_result
Alas, some users refused to take care of the rule and coerced the record as a list.
What was supposed to strike did at last some months ago.
For some reason, maybe to show users that the rule is given to be applied, the order of the components of the result record was reverted.
And the bad guys are punished.
Normal.
Yvan KOENIG (VALLAURIS, France) jeudi 16 janvier 2014 09:29:27