• 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: system events XML suite -- it seems to be caching and holding XML objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: system events XML suite -- it seems to be caching and holding XML objects


  • Subject: Re: system events XML suite -- it seems to be caching and holding XML objects
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Fri, 14 Oct 2005 11:18:40 -0400


Thanks. Yes -- Something like what you described seems to be what is going on.

I stuck the 'make new XML data' in a loop, followed by a 'log text of result' .
Looking at the log, it looks like 'result' get's translated into 'XML data "X"' ,
so it looks like what gets returned by 'make' is not the object, but a reference
by name to the object. However, in this case, the text returned is actually
the correct text of the last created object, rather than the first one created,
as in my initial problem, so it would seem to be somewhat indeterminate WHICH
one of an ambiguous reference gets returned.


And later:
    get every XML data whose name = "X"

returns:
{XML data "X", XML data "X", XML data "X", XML data "X", XML data "X", XML data "X", XML data "X", XML data "X"}


However, 'get first XML data' and 'get last XML data' seem to return the same
thing. So again, there seems to be something indeterminate about the order.



When I remove the name="X" from the properties, what get's returned as the
result is something like: XML data "untitled 9"
So it looks like System Events gives everything unnamed a unique name which
explains why those references work.


But in any case, it looks like I'm going to want to tell System Events to
delete the XML data after I've used it.


Does anyone know if the behavior of retaining these objects differs if
running from an application verses running from the Script Editor or other
environments ? If it's really being retained by System Events, I would
guess not. ( And in that case, I wonder whether it takes a reboot to clear
them, or just a logout/login ? )



-- Steve.


On Oct 13, 2005, at 7:13 PM, has wrote:




But can anyone please explain what's going on ?



Can't be bothered to reboot into Tiger to verify this, but I'd guess that when you make a new named XML data element, the make command returns a by-name reference to it, and when you make an unnamed XML data element it returns a by-index reference. That would explain the difference you see when creating named vs unnamed XML data elements.


Also, like most scriptable apps, it's perfectly legal to have multiple sibling elements with the same name. Note that the by-name reference form is actually the same as saying 'first <element> whose name = <whatever>'. Since new elements are created after existing ones, if you already have an element named "foo" and make a new one with the same name, a reference to 'item "foo"' will always return the first one. (Only the by-ID reference form is guaranteed always to refer to the same object.)

Anyway, I'd recommend you monitor the event log, run each line one at a time and observe its return value, and maybe also run 'tell app "System Events" to get every XML data' to see what objects SE is currently holding. It's a lot easier to understand what's going on in a complex script when you break it down and watch what's going on in each line, rather than run it all at once and try to figure out what's going on from the final result alone. Nothing like a bit of study and experimentation to make sense of things.


_______________________________________________ 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
References: 
 >Re: system events XML suite -- it seems to be caching and holding XML objects (From: has <email@hidden>)

  • Prev by Date: Re: Replying to messages whilst off line in the train
  • Next by Date: Re: date of question
  • Previous by thread: Re: system events XML suite -- it seems to be caching and holding XML objects
  • Next by thread: Re: system events XML suite -- it seems to be caching and holding XML objects
  • Index(es):
    • Date
    • Thread