• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: global variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: global variables


  • Subject: Re: global variables
  • From: Isaac Ordonez <email@hidden>
  • Date: Wed, 26 May 2004 14:06:25 -0700

The code I presented was part of a larger Xcode project I've been working on. As for passing a value to the keychain handler that was just done... well dunno... that's the way I got it to work so i kept it there. As for the "On clicked theObject" this is where I'm having the problems. Any references to my variable inside this call gives me the error that there is no defined variable.

According to the books I've been looking at once a variable is declared global it will work throughout the script regardless, unlike "local" variables which only work inside each subroutine. This is the part that's making my head bang against the wall.

Thanks for all your help on this bill,

Isaac Ordonez
Technology Support Specialist II
San Rafael City Schools
415.302.8114

On May 26, 2004, at 1:37 PM, Wallace, William wrote:

Works OMM (MacOS 9.2.2, AS 1.8.3), however. I'm wondering if the snippet you've posted is out of context and thus I'm not encountering the problem you are. First, I don't see why you've passed a value to your keychainpass handler when you don't make use of it in the actual handler. Second, it works without the global declaration:

set importpass to my keychainpass("password") as string

on keychainpass(myvalue)
try
tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to first key whose name is "Add User Info"
set endvalue to (password of theKey) as string
return endvalue
end tell
end tell
end try
end keychainpass

importpass
--> returns the expected value

Third, the "on clicked theObject, tell window of theObject..." lines of code look like a FaceSpan handler. Is it possible that problem has more to do with your FaceSpan project than the Applescript code? At what point do you get the variable not defined error message?

B!ll

Subject: global variables
To: Applescript <email@hidden>
From: Isaac Ordonez <email@hidden>
Date: Wed, 26 May 2004 11:13:40 -0700Ok,

I've read books on this, researched the heck outta it, and ever example I come up >with says this should work but it doesn't. All I want to to declare the values I get from >the keychain as global variables so they will work within my subroutines and inside >"on clicked theObject" etc. but when I do the following:

global importpass

set importpass to my keychainpass("password") as string

on keychainpass(myvalue)
try
tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to first key whose name is "Add User Info"
set endvalue to (password of theKey) as string
return endvalue
end tell
end tell
end try
end keychainpass
on clicked theObject
tell window of theObject
......

I get a variable "importpass" not defined. Is there something stupid I'm missing?

Isaac Ordonez
Technology Support Specialist II
San Rafael City Schools
415.302.8114
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: global variables
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: global variables (From: "Wallace, William" <email@hidden>)

  • Prev by Date: Re: global variables
  • Next by Date: Re: global variables
  • Previous by thread: Re: global variables
  • Next by thread: Re: global variables
  • Index(es):
    • Date
    • Thread