• 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: Compact Handlers Togo!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Compact Handlers Togo!


  • Subject: RE: Compact Handlers Togo!
  • From: "Bourque, Jason" <email@hidden>
  • Date: Thu, 16 Aug 2001 15:57:18 -0400

Confused? Maybe, let me explain again.

I constantly write script that have handlers that use properties and
globals. So in keeping track of everything I though it might be easier (not
neccesary better) to include the property function in a global try statement
for persistance.

So I do want the globals to be available (only if declared) to the rest of
the script. I am not sure if script objects allow for this accessing of
properties and globals. But in this global in a handler implementation it
does.

But for the text file that is a good idea. I use the same technique for
gathtering job settings for a script. How do you work it with say 20 to 30
properties or global variables? Do you check for a change in value everytime
you need to use one?

Thanks,

Jason Bourque
Senior Script Developer
Publishing Automation
MFS Investment Management
617-954-5312

> ----------
> From: email@hidden
> Sent: Thursday, August 16, 2001 3:30 PM
> To: email@hidden
> Subject: Re: Compact Handlers Togo!
>
> Togo - moving to West Africa?
>
> I think you are confused about scope. Properties and globals are elements
> of
> scripts (and script objects), not handlers. The whole point of "global" is
>
> that it is global for a script, not restricted to a handler (handlers use
> local variables). If you want a "portable" object with properties and
> globals, you want a script object.
>
> script john
> global gVariable
> on compactHandler()
> try
> --This will check to see if the global variable has a value
> gVariable
> --Increase the variable's value to show its value stays
> between
> runs
> set gVariable to gVariable + 1
> on error
> --First Initilizing of the variable
> set gVariable to 1
> end try
> end compactHandler
> end script
>
> tell john
> try
> gVariable
> --After Initializing of the variable we can see it
> --increase in value everytime we run the script
> activate me
> display dialog gVariable
> on error errmsg
> --On first run the global variable isn't initialized
> activate me
> display dialog errmsg
> end try
>
> --Call the handler which will initialize the global variable
> compactHandler()
> end tell
>
> I personally don't like using properties for values that need to persist.
> I
> read and write my data from and to text files instead. This has several
> advantages:
>
> 1) They can be manually reviewed and edited
> 2) They persist even when the script is edited
> 3) They can be shared more easily among multiple scripts.
>
> Jeff Baumann
> email@hidden
> www.linkedresources.com
>
>
> In a message dated 8/15/01 5:58:58 PM, Jason Bourque wrote:
>
> >Hello everyone,
> >
> >I have been thinking that the handlers I create aren't that portable.
> i.e.
> >Copy the handler. Any properties or globals associated with the handler
> must
> >be copied to the top of the script
> >
> >So, I thought including the Properties and Globals in the actual handler
> >would make it much more portable.
> >
> >First to treat globals like properties and have the last value of global
> >keep after a run.
> >
> >Below is the script that demonstrates what I have accomplished, but I am
> >looking for comments about it. i.e. If it is useful and am I
> understanding
> >the logic correctly, general comments.
> >
> >Please post all responses to the list, for I am in two locations with
> >different email.
> >
> >Thanks,
> >
> >--Save the following code as an applet and run a few times to see the
> >persistance of the global.
> >
> >on compactHandler()
> >
> > global gVariable
> >
> > try
> > --This will check to see if the global variable has a value
> > gVariable
> >
> > --Increase the variable's value to show it's value stays between
> >runs
> > set gVariable to gVariable + 1
> > on error
> >
> > --First Initilizing of the variable
> > set gVariable to 1
> > end try
> >
> >end compactHandler
> >
> >
> >try
> > gVariable
> >
> > --After Initializing of the variable we can see it
> > --increase in value everytime we run the script
> > activate me
> > display dialog gVariable
> >
> >on error errMsg
> >
> > --On first run the global variable isn't initialized
> > activate me
> > display dialog errMsg
> >
> >end try
> >
> >--Call the handler which will initialize the global variable
> >my compactHandler()
> >
> >Jason Bourque
> >Senior Script Developer
> >Publishing Automation
> >MFS Investment Management
> >617-954-5312
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users


  • Prev by Date: Can't read text file from 0
  • Next by Date: RE: Compact Handlers Togo!
  • Previous by thread: Re: Compact Handlers Togo!
  • Next by thread: RE: Compact Handlers Togo!
  • Index(es):
    • Date
    • Thread