Does anyone know how to tell if an attribute is empty? I need to write a DXL script that puts some of the "Object text" into the "Object Heading". However if there is no Object Text or if the object text only contains an embedded table or drawing, my script falls over. It doesn't crash or generate an error it just doesn't do anything. Is there a way I can check an attribute before I try and do anything with it?
adevicq 270002115539 Posts
Re: Detecting Empty Attributes2013-09-26T12:05:37ZThis is the accepted answer. This is the accepted answer.
You can use probeAttr_ or probeRichAttr_ to retrieve an attribute value. It always returns a value.
(probeAttr_(o, "my attribute") == "") returns true if the attribute is empty (or if the attribute does not exist or if o in null).
llandale 270001QM9N648 Posts
Re: Detecting Empty Attributes2013-09-26T16:14:19ZThis is the accepted answer. This is the accepted answer.
It's easier to comment on a script when it is posted.
There is an "hasSpecificValue(Object, AttrDef)" perm that sorts out actual values from those that are inherited or defaulted. It is a little clumsy, you first must get the AttrDef ad = find(mod, NameAttr).
I think your problem however is that you are retrieving the raw text from Object Text, which is null for Objects with only OLE. Although, that is what you want to do since Object Heading is type "String" and will only take basic rich text (bolding et tal).
- Value = o."Object Text"
- Value = probeAttr_(o, "Object Text")
- Value = richTextNoOLE(o."Object Text")
- Value = richTextWithOLE(o."Object Text")
- Value = probeRichAttr(o, "Object Text") // no OLE
- Value = probeRichAttr(o, "Object Text", true) // with OLE
I don't think parsing the rich text to find the part you WANT to put in Object Heading will work (e.g. a value in an OLE table inside the Object Text). Someone figured out how to do that but it was realistically hopeless.