Applescript Studio and cross-script variables

Discussion in 'Mac Programming' started by Keytachi, May 25, 2008.

  1. Keytachi macrumors regular

    Joined:
    Sep 14, 2006
    #1
    Hi everyone! I'm taking a few steps in AS and i'm having some trouble with the following:

    http://imagehax.com/images/95w5pmmw4u35sjssea55.png
    scripts: login; newacc; acclist

    when i press the Add account button (connected with "newacc"), the values in username and password are added to item 1 of UN and PW
    Code:
    property UN : {missing value, missing value, missing value, missing value}
    property PW : {missing value, missing value, missing value, missing value}
    
    in both newacc and acclist. it also creates a new menu item in the popup button (connected to acclist)
    Code:
    {title:item 1 of UN}
    When i choose an item from the popup button, it will tell the script "login" to set UN1 and PW1 to item 1 of UN and PW

    Code:
    on action theObject
    	if title of menu of popup button "accList" of window "theWindow" is item 1 of UN then
    		tell script "login.applescript"
    			set UN1 to item 1 of UN
    			set PW1 to item 1 of PW
    		end tell
    	end if
    end action
    
    all scripts have the properties UN and PW.
    my problem is that i'm not sure if this works, when i try to add a new account, i get the "invalid key form" error.

    Any ideas on how to make this more simple and/or how to fix this error?
     
  2. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #2
    Does the login applescript have a global variable named UN1 and PW1? Or are you trying to set the properties UN and PW in login?

    If you have a property UN and PW in login maybe take them out and change em to UN1 and PW1 and try it. The script may get the wrong values if the login also has the same-named properties in both scripts when you do the tell.
     
  3. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #3
    it has UN1 and PW1 as local variables.
    The error appears when i press the add account button, i can't even get to the login button :p
     

Share This Page