Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: button title problem



Chris,
As I suspected, it's a simple coercion issue. When you do
set newTitle to (xVal + cVal)
you are coercing two strings into a number, and then trying to set the title of theObject to a number, which gives unexpected results*. Simply coerce newTitle into a string as you set it:
set title of theObject to (newTitle as string)

Cheers,
Joe Weaks

* "unexpected results" means I don't understand why the visible title of the button changes to the number you are setting it to but a "get title" of the button returns "" an empty result.


On Dec 20, 2003, at 5:24 AM, Chris Eneman wrote:
Oops ... haven't noticed this before:
when i do the display dialog the first time I click I get 3 values: 0,1,1
the second time I get ...,1,1 where ... is nothing ...

strange

Op 20-dec-03 om 06:21 heeft Joseph Weaks het volgende geschreven:
Chris,
When you put a
display dialog cVal & return & xval & return & newTitle
before the set title line, are all the variables as you'd expect, even the second, third time around?
Cheers,
Joe Weaks


On Dec 19, 2003, at 9:43 PM, Chris Eneman wrote:
I have a problem setting a buttons title more than once.
I figured it would be quite simple but I just can't seem to find a solution:

I have a text field where one can enter a numeric value.
I want to that value to be added to the value of the button, ie the title of the button, each time it is clicked

hence this code:

on clicked theObject

set cVal to contents of text field "c" of window "main"

set xVal to title of theObject

set newTitle to (xVal + cVal)

set title of theObject to newTitle

end clicked

This works fine, but it only works once ! Wahetever I seem to try, the title of the button seems to be sticked to the initial value, being 0.
If I change cVal, newTitle changes to (0+cVal). When I click again, it remains (0+cVal)

anyone ?


regards

chris
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.

References: 
 >button title problem (From: Chris Eneman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.