Like copy attributes, but instead of doing it for the whole module, I need it to copy attribute values for only the objects in my current view. Anyone modify or come up with a script for that?
|
Re: copying the value of one attribute to another
Hi,
Object o
Module m = current
string fromAttr = "some attribute"
string toAttr = "some other attribute"
for o in m do {
o.toAttr = probeAttr_(o, fromAttr)
}
|
Re: copying the value of one attribute to another
The "for obj in mod" loop finds currently displayed objects and should work for this particular use. I seem to have a minority opinion about that loop in that I almost always use the "for obj in entire mod" loop, then explicitly reject objets I don't care about, typically "if (isDeleted(obj)) continue" and "if (table(obj) or row(obj) or cell(obj)) continue". I do not want my scripts routinely dependant on the current view, unless the script is specifically designed to be sensitive to that (such as your script). string set(Attr__ To,Attr__ From) Use: string ErrMess = set(oNew."NameAttr", oOld."NameOtherAttr")
noError() Object o = null set(o."New", o."Old") string Err1 =lastError() print "Err1: " Err1
|
Re: copying the value of one attribute to another tightly controlled copy, so the first snippet worked great. |
Re: copying the value of one attribute to another cliff.sadler - Fri Jan 14 13:54:06 EST 2011 |
Re: copying the value of one attribute to another llandale - Fri Jan 14 14:56:31 EST 2011 string probeRichAttr_(Object o, string attrName) string probeRichAttr_(Object o, string attrName, false) |
Re: copying the value of one attribute to another bullbala - Tue Jan 18 08:06:15 EST 2011 See ../lib/dxl/utils/attrutil.inc
|
Re: copying the value of one attribute to another llandale - Tue Jan 18 10:29:38 EST 2011
I'm trying to use the following to cut OLE objects (1 OLE per object) from the Object Text attribute into an attribute called "LD 2". The script seems like it's cutting the OLE's ok, but it is not populating the "LD 2" attribute. LD 2 is type text just like Object Text.
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD 2"
for o in m do {
o.toAttr = set(o.fromAttr, o.toAttr)
}
|
Re: copying the value of one attribute to another SystemAdmin - Fri Mar 22 14:34:41 EDT 2013
I'm trying to use the following to cut OLE objects (1 OLE per object) from the Object Text attribute into an attribute called "LD 2". The script seems like it's cutting the OLE's ok, but it is not populating the "LD 2" attribute. LD 2 is type text just like Object Text.
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD 2"
for o in m do {
o.toAttr = set(o.fromAttr, o.toAttr)
}
o.toAttr = set(o.fromAttr, o.toAttr)
set(o.toAttr, o.fromAttr)
|
Re: copying the value of one attribute to another SystemAdmin - Fri Mar 22 14:45:32 EDT 2013 o.toAttr = set(o.fromAttr, o.toAttr)
set(o.toAttr, o.fromAttr)
you're absolutely right about the flip flop and taking off the prefix. The following copied the OLE from object text to my other attribute just like I wanted.
//set(oTo."NameAttr", oFrom."NameOtherAttr")
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD"
for o in m do {
set(o.toAttr, o.fromAttr)
}
|
Re: copying the value of one attribute to another SystemAdmin - Fri Mar 22 15:48:32 EDT 2013
you're absolutely right about the flip flop and taking off the prefix. The following copied the OLE from object text to my other attribute just like I wanted.
//set(oTo."NameAttr", oFrom."NameOtherAttr")
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD"
for o in m do {
set(o.toAttr, o.fromAttr)
}
and the following will delete the original OLE as well after the copy
//set(oTo."NameAttr", oFrom."NameOtherAttr")
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD"
for o in m do {
set(o.toAttr, o.fromAttr)
oleDelete (o)
}
|
Re: copying the value of one attribute to another SystemAdmin - Fri Mar 22 15:58:06 EDT 2013
and the following will delete the original OLE as well after the copy
//set(oTo."NameAttr", oFrom."NameOtherAttr")
Object o
Module m = current
string fromAttr = "Object Text"
string toAttr = "LD"
for o in m do {
set(o.toAttr, o.fromAttr)
oleDelete (o)
}
I am guessing that oleDelete(Object) only deletes the 1st OLE in Object Text. Test this with text with 3 OLEs:
int Count = 0
bool More = false
while(More)
{ More = oleDelete(o)
if (More) print "OLE Deleted\t#" Count++
}
|