Re: Property and variable
Re: Property and variable
- Subject: Re: Property and variable
- From: Jan Bultereys <email@hidden>
- Date: Fri, 03 Nov 2006 18:30:24 +0100
- Thread-topic: Property and variable
Title: Re: Property and variable
Thanks guys / emmanuel, yes this is what I looked for.
Have a nice weekend
jan
From: "Mark J. Reed" <email@hidden>
Date: Fri, 3 Nov 2006 12:26:07 -0500
To: Jan Bultereys <email@hidden>
Cc: "email@hidden" <email@hidden>
Subject: Re: Property and variable
On 11/3/06, Jan Bultereys <email@hidden> wrote:
Sorry for the "link" word .... English is not my mother language... I meant set the value (or content) to a variable...
set theFoldersinput to read DATAFILE as list
set the theFolders to theFoldersinput
on findTheFile(PictureName)
set the theFolders to theFoldersinput
end findTheFile
What would you suggest to make the variable theFolders available in the handler?
Two options. First, pass the extra information to the handler directly, making it obvious that it needs it. This might be inconvenient if called from places that don't have the information, or if there's just a lot of calls to change:
on findTheFile(Picturename, theFoldersinput)
...
end
findTheFile(somePictureName, myfolders)
Or, as Emmanuel said, just declare the variable as "global" within the handler:
on findTheFile(Picturename)
global theFoldersinput
...
end
From: "Mark J. Reed" < email@hidden <mailto:email@hidden> >
Date: Fri, 3 Nov 2006 11:38:04 -0500
To: Jan Bultereys <email@hidden>
Cc: "email@hidden" < email@hidden <mailto:email@hidden> >
Subject: Re: Property and variable
On 11/3/06, Jan Bultereys <email@hidden <mailto:email@hidden> > wrote: Ok, does this mean I can not link a variable to a property?
What do you mean "link"? There's no linkage going on. Even if what you were trying to do worked:
set a to 1
property b: a
A later change to a would not affect the value of b, nor vice-versa. They are two separate entities that you have just initialized to the same value.
But properties are defined and initialized before any of the code is actually run. So that doesn't work because the "set a to 1" line has not been run yet (though it's been compiled) at the time that the "property b: a" line is compiled.
Well if I use:
Set "variable1" to "variable2"
It won't be "available" in the handlers.
The fact that handlers can't see "global" variables is generally considered a good thing. :) If your handler needs the value of a variable, why not pass it in as a parameter when you call the handler?
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden