Can't make type into string - variable question

Discussion in 'Mac Programming' started by hamw, Nov 7, 2010.

  1. hamw macrumors newbie

    Oct 3, 2008

    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?
  2. HiRez macrumors 603


    Jan 6, 2004
    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:

    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.
  3. hamw thread starter macrumors newbie

    Oct 3, 2008
    Oops. Turned out I had an extra _ in one of the variables. Thanks!

Share This Page