I'm using for for a year but now I have to modify small scripts and I'm a newbie with DXL
. I have searched in before questions but I don't know how I can do it.
I have to develope a script that analyzes all objects in the same formal module to extract from each "object text" different strings separated by tab, to be written in other different attributes of the same object.
The formal module contents has been imported from Word. In that way that normal text format is defined as "object text" and every Title style is associated to a given level heading. In that way each object is provided with object heading or object text (but not both at the same time). Objects with object heading doesn't require any further action. However for objects provided with object text, I have to extract from object text some atributes separated by tabs.
For example a typical object text could be:
NNNN TEXT/TABLE/OLE OBJECT/ANY OTHER STRING (XXXXXX) (YYYYYY)
After apply the script it should be converted as:
Attribute 1: NNNN
Object Text: TEXT/TABLE/OLE OBJECT/ANY OTHER STRING
Attribute 2: XXXXXX
Attribute 3: YYYYYY
I have small script as example but I have passed all the morning trying to modify it to get I need but I can't do it:
Object o = current
//bool get_text(Object o) {return o."Object Heading" "" != ""}
string get_text(Object o)
{
if (o."Object Heading" "" != "")
return "Object Heading"
else
return "Object Text"
}
Regexp r_id = regexp "(http://0-9a-z/.+) "
for o in current Module do
{
string texto = o.(get_text(o))
if (r_id text)
{
o."Attribute 1" = textmatch 1
string input = richTextWithOle(o.(get_text(o)))
string output = cutRichText(input, 0, length(textmatch 1))
o.(get_text(o)) = richText(output)
}
}
Best Answer
This was a complicated one, but I think I have it figured out. Thanks for posting this because I may find it useful in the future as well.
I tried this out and it seems to work:
Let me know if this gives you any trouble or if you want more detailed explination of the code.
EDIT: I updated the above code to take care of the issues you mentioned. It should be all set now. Let me know if you have any more trouble with it.