referencing Object Level or Object Number

anyone have a slick way of exposing Object Level or Object Number to a script?
They come up as unkown attributes. Kind of remember that they were "derived".

Need to identify a specific section heading object without using the Absolute Number if possible.
SystemAdmin - Tue May 04 12:21:55 EDT 2010

Re: referencing Object Level or Object Number
SystemAdmin - Tue May 04 13:30:18 EDT 2010

Object Level - int level(Object)
Object Number - string number(Object)

also Object Identifier "pseudoattribute" - string identifier(Object)

Re: referencing Object Level or Object Number
gkane - Tue Dec 07 12:08:03 EST 2010

SystemAdmin - Tue May 04 13:30:18 EDT 2010
Object Level - int level(Object)
Object Number - string number(Object)

also Object Identifier "pseudoattribute" - string identifier(Object)

I need access to Object Number as well...got the error message mentioned.

Here's my code to set-up the variable:

objToTemp = oTo."Object Number" (note: objToTemp is a string)

What would the code be to get access to Object Number as referenced in Pekka's reply?

Thanks!

Re: referencing Object Level or Object Number
llandale - Tue Dec 07 12:40:51 EST 2010

gkane - Tue Dec 07 12:08:03 EST 2010
I need access to Object Number as well...got the error message mentioned.

Here's my code to set-up the variable:

objToTemp = oTo."Object Number" (note: objToTemp is a string)

What would the code be to get access to Object Number as referenced in Pekka's reply?

Thanks!

Level, Number, and Identifier are not true 'attributes'. You access those values as follows:

Object    obj = current(()
int     iLevel  = level(obj)            // NOT obj."Object Level"
string  ParaNum = number(obj)           // NOT obj."Object Number"
string  ObjId   = identifier(obj)       // NOT obj."Object Identifier"
        //  those 3 perms are 'nice' and you can indeed use them in expressions:
print "Psuedo Attrs are: " level(obj) "\t" identifier(obj) "\t" number(obj) "\n"


Now the reason these are not actually 'attributes' is that the values may change even though you don't modify the object. level changes when you move the object or one of its ancestors. number changes as you move and when you insert other objects ahead of this one. identifier changes when you modify the module level attribute "Prefix".

Now the reason you cannot access these 'attributes' like others, e.g. obj."Object Level" is because ... because the sky is blue.

However, the 'retrieve attribute value' function "probeAttr_" and its siblings will indeed accept "Object Level", "Object Number", and "Object Identifier" as 'attribute' names, but that's because it has code to take that into account. You can, and should, do this:
{code{
string ReqText = probeAttr_(obj, "Requirement") // raw
string ObjID = probeAttr_(obj, "Object Identifier")
string Text1 = probeRichAttr_(obj, "Object Text") // rich text no OLE
string Text2 = probeRichAttr_(obj, "Object Text", true) // rich text yes OLE
{code}
That function does nice checking such as no such attr or no-read access, and simply returns null when there's an issue; whereas this causes DXL errors:
string ReqText = obj."Requirments") // when the attr doesn't exist

 

  • Louie

 

Re: referencing Object Level or Object Number
gkane - Tue Dec 07 13:29:28 EST 2010

llandale - Tue Dec 07 12:40:51 EST 2010

Level, Number, and Identifier are not true 'attributes'. You access those values as follows:

Object    obj = current(()
int     iLevel  = level(obj)            // NOT obj."Object Level"
string  ParaNum = number(obj)           // NOT obj."Object Number"
string  ObjId   = identifier(obj)       // NOT obj."Object Identifier"
        //  those 3 perms are 'nice' and you can indeed use them in expressions:
print "Psuedo Attrs are: " level(obj) "\t" identifier(obj) "\t" number(obj) "\n"


Now the reason these are not actually 'attributes' is that the values may change even though you don't modify the object. level changes when you move the object or one of its ancestors. number changes as you move and when you insert other objects ahead of this one. identifier changes when you modify the module level attribute "Prefix".

Now the reason you cannot access these 'attributes' like others, e.g. obj."Object Level" is because ... because the sky is blue.

However, the 'retrieve attribute value' function "probeAttr_" and its siblings will indeed accept "Object Level", "Object Number", and "Object Identifier" as 'attribute' names, but that's because it has code to take that into account. You can, and should, do this:
{code{
string ReqText = probeAttr_(obj, "Requirement") // raw
string ObjID = probeAttr_(obj, "Object Identifier")
string Text1 = probeRichAttr_(obj, "Object Text") // rich text no OLE
string Text2 = probeRichAttr_(obj, "Object Text", true) // rich text yes OLE
{code}
That function does nice checking such as no such attr or no-read access, and simply returns null when there's an issue; whereas this causes DXL errors:
string ReqText = obj."Requirments") // when the attr doesn't exist

 

  • Louie

 

Very good.....thanks!

GK