Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hamw

macrumors newbie
Original poster
Oct 3, 2008
6
0
Hi,

I am trying to write a relatively simple applescript with a transfer of one variable value to another as follows:


set value of variable "Button_1" to value of variable "Preset_1" as string



The variable value is a word, Guitar, not a number. The compiler keeps coming back and saying that it "can't make variable "Preset_1" into type string". I've tried setting the value to a system variable as follows:



set Button_1a to value of variable "Preset_1"
set value of variable "Button_1" to value of variable Button_1a


same error, still doesn't work. Any ideas?
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
You've got some weird syntax there and it's hard to tell what you're trying to do. The names of variables (as opposed to the value of a string assigned to a variable) are not enclosed in quotes, and you don't need to type the word "variable". Normally you just assign variables with a more simple syntax, like this:

Code:
set a to "Value A"
set b to a
-- [The variable named] b now contains [the string] "Value A"

Is Button_1 the name of a variable, or an interface object (an actual button)? If you post the entire code where you assign variables it might help. You only need to use "as string" if it's not already a string, to coerce it into a string type from another type.
 

hamw

macrumors newbie
Original poster
Oct 3, 2008
6
0
Oops. Turned out I had an extra _ in one of the variables. Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.