home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Targeting objects in script < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  2.7 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Targeting objects in scripts
  2. Sent:        6/13/96 11:50 AM
  3. Received:    6/13/96 11:01 AM
  4. From:        Greg Friedman, friedman@cognosis.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. Scott Daniels asked:
  9. > I am fairly new to scripting, so please forgive any ignorance I may show.
  10. >My question is this: I have been told that one can write a script like:
  11. >
  12. > Set Position of Shape whose Color is {0,0,0} to {50,25}
  13. >
  14. > In this script, the shape is specified via its color property. Upon
  15. >examination of FWMScriptable >however, I can only specify elements by
  16. >index et. al. and the name property only. Does the OpenDoc
  17. > scripting archictecture support object specification by any object
  18. >property? If it does, then
  19. >do I need to override GetContainedObject in order to resolve objects by
  20. >properties other than name?
  21.  
  22. This sort of thing works in ODF without much effort. When the direct object
  23. of an apple event is a "whose clause", the target of the event's object
  24. accessor is called with a specifier of form whose. The application or part
  25. has two options: resolve the whose clause itself, or return
  26. errAEEventNotHandled in response to the object access, and let the OSL
  27. resolve the whose clause.
  28.  
  29. Greg Anderson wrote an article for an issue of Develop that describes a
  30. method for resolving whose clauses manually. In most cases, its a lot of
  31. work, and you don't get a justifiable performance improvement. ODF does not
  32. resolve whose clauses manually, it relies on the OSL.
  33.  
  34. The OSL resolves whose clauses as follows:
  35.  
  36. Calls your count proc to determine the number of objects of the class being
  37. specified in the whose clauses.
  38. Calls your object accessor for each of the possible objects, specificing
  39. each object by index.
  40. For each object, the property or properties being tested are requested.
  41. For each property, your compareproc is called, and the truth of the whose
  42. clause is assessed.
  43. For each object that meets the specifications of the whose clause, the
  44. object is added to a collection.
  45.  
  46. Once the collection of satisfactory objects has been established, the event
  47. is dispatched to your event handler with the collection as the direct
  48. object.
  49.  
  50. ODF makes most of this work automatically. To support the whose clause you
  51. posed, your shape object must do the following:
  52.  
  53. Implement "HasProperty" and return TRUE for pColor and pPosition.
  54. Implement "GetProperty" and return pColor when requested.
  55. Implement "SetProperty" and set pPosition when appropriate.
  56.  
  57. Everything else is automatic, including full undo/redo support.
  58.  
  59. gsf.
  60.  
  61.  
  62. ___________________________________________________________
  63.   Greg Friedman                      ODF Engineering
  64. Apple Computer
  65.  
  66.