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 / August 96 / Re Scripting Problem.1 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Scripting Problem
  2. Sent:        8/5/96 3:21 PM
  3. Received:    8/5/96 2:32 PM
  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. Serge Froment wrote:
  9. > Dear ODF Experts:
  10. >
  11. > I have implemented scripting similar to ODFDraw except that my
  12. > FW_MScriptable objects are generated on the fly by my FW_CElementIterator
  13. > and they are reference counted so they are released when no longer needed
  14. > (I override AcquireScriptable and ReleaseScriptable in a way similar to
  15. > FW_CScriptableCollection).
  16. >
  17. > When I write a script like "get myProperty of first myClass", I actually
  18. > get the property. But when I write a script like "get first myClass", I get
  19. > an error message saying "Can't make myClass 1 into myClass 1". Similar
  20. > script with ODFDraw returns a result like "shape 1 of application ODFDraw
  21. > Sample".
  22. >
  23. > I have stepped the code from FW_MScriptable::GetContainedObject and it does
  24. > its job without error, including FW_InsertScriptableIntoDesc. However, I
  25. > don't really understand what FW_InsertScriptableIntoDesc does and where the
  26. > error comes from.
  27. >
  28. > Does someone have a clue?
  29.  
  30. Serge,
  31.  
  32. Sorry for the delay in answering your scripting questions.
  33.  
  34. As you learned, FW_MScriptable::GetProperty has a default implementation
  35. for getting a scriptable object by index. FW_MScriptable::GetProperty,
  36. however, doesn't return TRUE for the "pIndex" property. This is intentional
  37. and, if you think about it, makes sense. FW_MScriptable::HasProperty is a
  38. virtual method that returns a boolean indicating whether the scriptable
  39. object has the specified property. The only property ODF requires all
  40. scriptable objects to support is pClass. Some classes of objects can be
  41. specified by numeric index, others can't. The same is true for name, id,
  42. and any other specifier form. When ODF needs to access a specific property
  43. of a specific object, it calls the HasProperty method of the object to
  44. determine whether or not the specific property is available from the
  45. object. If HasProperty returns TRUE, ODF will either request the property
  46. value, or create a property specifier, depending on the operation in
  47. progress. If HasProperty returns FALSE, ODF will return an error, throw an
  48. exception, or do whatever is appropriate within the context of the current
  49. operation.
  50.  
  51. By default, scriptable objects don't support numeric index, so GetProperty
  52. for pIndex returns FALSE. There is, however, an obvious and simple
  53. algorithm for getting the numeric index of an object for object classes
  54. that do support pIndex. This algorithm is implemented in
  55. FW_MScriptable::GetProperty, for the case where pIndex is specified. If you
  56. are creating an object class that supports pIndex, you MUST override
  57. GetProperty and return true when pIndex is specified. If the default
  58. implementation for retrieving an object's index does not work for your
  59. implementation, you'll need to override GetProperty and provide an
  60. implementation that works.
  61.  
  62. Hope this helps,
  63.  
  64. Greg.
  65.  
  66.  
  67.  
  68. ___________________________________________________________
  69.  Greg Friedman       ODF Engineering        Apple Computer
  70.  
  71.  
  72.