• 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: Script application "bundles" that are read-only: error when quitting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script application "bundles" that are read-only: error when quitting


  • Subject: Re: Script application "bundles" that are read-only: error when quitting
  • From: Paul Berkowitz <email@hidden>
  • Date: Sat, 06 Aug 2005 16:47:03 -0700
  • Thread-topic: Script application "bundles" that are read-only: error when quitting

On 7/18/05 7:57 AM, "has" <email@hidden> wrote:

> Stephen Jonke wrote:
>
>> So I guess the real question is, is there way to have a property or global
>> variable that is not persistent and thus does not result in an attempt to
>> save the data to the script application itself?
>
> If it's a stay-open applet that handles multiple events, no. If it's a simple
> batch-processing script, here's the workaround to use:
>
> on main()
>     -- [main code here]
>     return
> end main
>
> on run
>     local scpt
>     copy me to scpt
>     scpt's main()
> end run
>
> Also, file a feature request with Apple for an SE 'Save As' option that allows
> you to create non-persistent applets.


The copy scpt is unnecessary. This works just as well:


on main()
    -- [main code here]
    return
end main

on run
    main()
end run

For example, this script saved as an application never changes its
modification date or time, no matter when or how often you run it:

on main()
    set a to random number 1000
    set b to some item of {"a", "b", "c", "d", "e", "f"}
    display dialog (b & a)
    return
end main

on run
    main()
end run


But that doesn't answer Stephen's question about having a non-persistent
property or global. The answer to that is No. All variables must be local,
so you need to pass whatever variables need to be accessed in other handlers
as parameters to those handlers, and do without globals or properties.
That's usually not too hard:

on main()
    set a to random number 1000
    set b to some item of {"a", "b", "c", "d", "e", "f"}
    my subroutine(a, b)
    return
end main

on subroutine(a, b)
    display dialog (b & a)
end subroutine

on run
    main()
end run


Again, no change in modification date. But no properties either.
--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Scripting TextEdit Save As HTML?
  • Next by Date: Re: Safari bookmarks - adding
  • Previous by thread: Re: Quitting from an idle handler
  • Next by thread: Re: Script application "bundles" that are read-only: error when quitting
  • Index(es):
    • Date
    • Thread