home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Scripting Problem
- Sent: 8/5/96 3:21 PM
- Received: 8/5/96 2:32 PM
- From: Greg Friedman, friedman@cognosis.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Serge Froment wrote:
- > Dear ODF Experts:
- >
- > I have implemented scripting similar to ODFDraw except that my
- > FW_MScriptable objects are generated on the fly by my FW_CElementIterator
- > and they are reference counted so they are released when no longer needed
- > (I override AcquireScriptable and ReleaseScriptable in a way similar to
- > FW_CScriptableCollection).
- >
- > When I write a script like "get myProperty of first myClass", I actually
- > get the property. But when I write a script like "get first myClass", I get
- > an error message saying "Can't make myClass 1 into myClass 1". Similar
- > script with ODFDraw returns a result like "shape 1 of application ODFDraw
- > Sample".
- >
- > I have stepped the code from FW_MScriptable::GetContainedObject and it does
- > its job without error, including FW_InsertScriptableIntoDesc. However, I
- > don't really understand what FW_InsertScriptableIntoDesc does and where the
- > error comes from.
- >
- > Does someone have a clue?
-
- Serge,
-
- Sorry for the delay in answering your scripting questions.
-
- As you learned, FW_MScriptable::GetProperty has a default implementation
- for getting a scriptable object by index. FW_MScriptable::GetProperty,
- however, doesn't return TRUE for the "pIndex" property. This is intentional
- and, if you think about it, makes sense. FW_MScriptable::HasProperty is a
- virtual method that returns a boolean indicating whether the scriptable
- object has the specified property. The only property ODF requires all
- scriptable objects to support is pClass. Some classes of objects can be
- specified by numeric index, others can't. The same is true for name, id,
- and any other specifier form. When ODF needs to access a specific property
- of a specific object, it calls the HasProperty method of the object to
- determine whether or not the specific property is available from the
- object. If HasProperty returns TRUE, ODF will either request the property
- value, or create a property specifier, depending on the operation in
- progress. If HasProperty returns FALSE, ODF will return an error, throw an
- exception, or do whatever is appropriate within the context of the current
- operation.
-
- By default, scriptable objects don't support numeric index, so GetProperty
- for pIndex returns FALSE. There is, however, an obvious and simple
- algorithm for getting the numeric index of an object for object classes
- that do support pIndex. This algorithm is implemented in
- FW_MScriptable::GetProperty, for the case where pIndex is specified. If you
- are creating an object class that supports pIndex, you MUST override
- GetProperty and return true when pIndex is specified. If the default
- implementation for retrieving an object's index does not work for your
- implementation, you'll need to override GetProperty and provide an
- implementation that works.
-
- Hope this helps,
-
- Greg.
-
-
-
- ___________________________________________________________
- Greg Friedman ODF Engineering Apple Computer
-
-
-