So I have a simple, not very long at all, DXL layout script that compares two attributes within a module and shows the differences in a column. My only problem, however, is that for some reason it is showing the differences 30 times in a row (not just once). I was wondering if someone could take a quick look and be able to see why this is happening. My script is as follows:
//compareAttributes
Module mnew = current
//Attributes to be compared
string attribut1 = "TPRC_1";
string attribut2 = "TPRC_2";
//Check whether attributes exist
AttrDef ad
string Text=""
if(exists(attribute attribut1)&&exists(attribute attribut2))
{
//Compare Attributes
if(obj.attribut1"" == obj.attribut2"")
display "true"
else
for ad in mnew do
{
Buffer bufCur = create()
bufCur=obj.attribut1""
Buffer bufOld = create()
bufOld=obj.attribut2""
if (bufCur!=bufOld)
{
Buffer bufDiff = create()
diff(bufDiff, bufOld, bufCur, "\\b\\cf1\\strike ", "\\b\\cf3\\ul ")
Text = Text stringOf(bufDiff) " \n"
delete(bufDiff)
}
delete(bufOld)
delete(bufCur)
}
displayRichWithColor(Text)
}
else if(!exists(attribute attribut1))
display "Attribut1 does not exist";
else if(!exists(attribute attribut2))
display "Attribut2 does not exist";
Zooby - Wed Aug 22 13:40:34 EDT 2012 |
|
Re: Attribute Compare DXL llandale - Wed Aug 22 14:08:34 EDT 2012
Get rid of this loop:
This statement is always false ..err.. true; it compares the variables but you want to compare the contents:
But you don't need that anyway, you compared contents further up.
This "else" clause needs braces {}:
-Louie
|
|
Re: Attribute Compare DXL Zooby - Wed Aug 22 14:54:55 EDT 2012 llandale - Wed Aug 22 14:08:34 EDT 2012
Get rid of this loop:
This statement is always false ..err.. true; it compares the variables but you want to compare the contents:
But you don't need that anyway, you compared contents further up.
This "else" clause needs braces {}:
-Louie
Thank you! That worked perfectly. Now, however, I just wanted to add a bit where for the first buffer it would use Object Heading for the first attribute in the compare if the main column is an object heading, and it would use Object Text for the same first attribute (in the compare) if the main column is object text for each individual object. I don't know if this is possible (I don't know if the obj.attribut1 can have attribut1 change for individual objects). As an example I tried putting this in near the beginning of the script:
string attribut2 = "TPRC_2";
string one = "Object Heading";
string two = "Object Text";
if (obj.one"" != "") then
{
string attribut1 = "Object Heading"
}
if (obj.two"" != "") then
{
string attribut1 = "Object Text"
}
|
|
Re: Attribute Compare DXL llandale - Thu Aug 23 09:31:28 EDT 2012 Zooby - Wed Aug 22 14:54:55 EDT 2012
Thank you! That worked perfectly. Now, however, I just wanted to add a bit where for the first buffer it would use Object Heading for the first attribute in the compare if the main column is an object heading, and it would use Object Text for the same first attribute (in the compare) if the main column is object text for each individual object. I don't know if this is possible (I don't know if the obj.attribut1 can have attribut1 change for individual objects). As an example I tried putting this in near the beginning of the script:
string attribut2 = "TPRC_2";
string one = "Object Heading";
string two = "Object Text";
if (obj.one"" != "") then
{
string attribut1 = "Object Heading"
}
if (obj.two"" != "") then
{
string attribut1 = "Object Text"
}
You need to declare it, THEN conditionally set the value. In your case variable "attribut1" ceases to exist (is "undefined")after the "then" and "else" clauses (end brace "}")
-
int i = 0
-
if (true) then {int i = 4, j = 3} // two new variables; confusing when i is same name as i defined above
-
print i "\n" // prints 0, not 4
-
print j "\n" // j undefined
In your case:
-
string attribut1
-
if (!null obj."Object Heading" "") //
-
then attribut1 = "Object Text"
-
else attribut1 = "Object Heading"
However, I'd be tempted also to do just a single retrieval:
-
Buffer bufFrom = create()
-
bufFrom = obj."Object Heading"
-
if (length(bufFrom) == 0) then bufFrom = obj."Object Text"
-Louie
|
|
Re: Attribute Compare DXL Praveenrc - Wed Oct 23 13:33:34 EDT 2013
Instead of strings in attributes, if the attributes contains ole objects ....how to find that attributes contain ole objects??
and I want the script to print the result as
" is "
ole object in attribute1
"was"
ole object in attribute
your help is appreciated , thanks
|
|
Re: Attribute Compare DXL Zooby - Wed Oct 23 14:03:45 EDT 2013 Praveenrc - Wed Oct 23 13:33:34 EDT 2013
Instead of strings in attributes, if the attributes contains ole objects ....how to find that attributes contain ole objects??
and I want the script to print the result as
" is "
ole object in attribute1
"was"
ole object in attribute
your help is appreciated , thanks
My experience has not gone so far as to deal with OLE objects much. If it is comparing them that you want to do, then I don't think it's possible to compare OLE objects. I could be wrong, however.
|
|
Re: Attribute Compare DXL Mathias Mamsch - Wed Oct 23 14:46:26 EDT 2013 llandale - Wed Aug 22 14:08:34 EDT 2012
Get rid of this loop:
This statement is always false ..err.. true; it compares the variables but you want to compare the contents:
But you don't need that anyway, you compared contents further up.
This "else" clause needs braces {}:
-Louie
Just one remark @Louie - there is indeed a content comparison in DXL for Buffers. Run this code:
Buffer b1 = create(); b1 = "DEF";
Buffer b2 = create(); b2 = "DEF";
bool bNotEqual = b1 != b2; // if what you say is true, this should be true
bool bEqual = b1 == b2; // if what you say is true, this should be false
print "bNotEqual (if false, then comparison was performed): " bNotEqual "\n"
print "bEqual (if true then comparison was performed): " bEqual "\n"
Regards, Mathias
|
|
Re: Attribute Compare DXL llandale - Thu Oct 24 10:27:23 EDT 2013 Mathias Mamsch - Wed Oct 23 14:46:26 EDT 2013
Just one remark @Louie - there is indeed a content comparison in DXL for Buffers. Run this code:
Buffer b1 = create(); b1 = "DEF";
Buffer b2 = create(); b2 = "DEF";
bool bNotEqual = b1 != b2; // if what you say is true, this should be true
bool bEqual = b1 == b2; // if what you say is true, this should be false
print "bNotEqual (if false, then comparison was performed): " bNotEqual "\n"
print "bEqual (if true then comparison was performed): " bEqual "\n"
Regards, Mathias
I sit corrected. Browsing the doors.exe I see these "==" functions:
-
Filter ::==(Fattr_,string)
-
Permission ::==(Permission,Permission)
-
bool ::==(_xx,_xx)
-
-
bool ::==(ModuleVersion,ModuleVersion)
-
bool ::==(Buffer,Buffer)
-
bool ::==(real,real)
-
bool ::==(Date,Date)
-
bool ::==(string,string)
-
bool ::==(char,char)
-
bool ::==(int,int)
Ignoring the 1st three, it appears the others indicate "==" means "are contents the same?". I wonder are there other data types that actually HAVE contents, or are all the others comparing only Addresses? What does the 3rd one mean?
- Louie
PS. "Browsing the doors.exe" is the only VooDoo I DooDoo.
|
|
Re: Attribute Compare DXL llandale - Thu Oct 24 10:31:50 EDT 2013 Zooby - Wed Oct 23 14:03:45 EDT 2013
My experience has not gone so far as to deal with OLE objects much. If it is comparing them that you want to do, then I don't think it's possible to compare OLE objects. I could be wrong, however.
These perms work:
-
bool containsOle(Attr__)
-
int oleCount(Attr__)
e.g.
-
if (containsOle(o."MyTextAttr")) then get the OLE
-Louie
The "bool oleIsObject(Object)" perm considers only "Object Text".
|
|
Re: Attribute Compare DXL Mathias Mamsch - Thu Oct 24 11:47:15 EDT 2013 llandale - Thu Oct 24 10:27:23 EDT 2013
I sit corrected. Browsing the doors.exe I see these "==" functions:
-
Filter ::==(Fattr_,string)
-
Permission ::==(Permission,Permission)
-
bool ::==(_xx,_xx)
-
-
bool ::==(ModuleVersion,ModuleVersion)
-
bool ::==(Buffer,Buffer)
-
bool ::==(real,real)
-
bool ::==(Date,Date)
-
bool ::==(string,string)
-
bool ::==(char,char)
-
bool ::==(int,int)
Ignoring the 1st three, it appears the others indicate "==" means "are contents the same?". I wonder are there other data types that actually HAVE contents, or are all the others comparing only Addresses? What does the 3rd one mean?
- Louie
PS. "Browsing the doors.exe" is the only VooDoo I DooDoo.
The third one is actually the one that compares anything else (as long as the datatype is the same on the left side). In DXL if you use those underscore types the order in which you define functions actually matters. The ones that you declare last take precedence over the ones you declare first. You can use this to create functions that work on any type, but have special implementations for certain types.
Note that the underscore types stand for any type, but if you use the same underscore type in a function
/*
bool compare (_x A, _y B) {
print "You can compare variables with different types:"
return (A int == B int )}
*/
bool compare (_xx A, _xx B) {
print "You can only compare variables of the same type:"
return (A int == B int )
}
bool compare (int A, int B) {
print "Special integer comparison (Note: nothing equals 7):"
return (A == B) && A != 7
}
Folder fldA = folder "/"; Folder fldB = null; Folder fldC = folder "/";
Project p = project "/";
print compare(fldA, fldB) "\n"
print compare(fldA, fldC) "\n"
// print compare(fldA, p) "\n" // does not work with Same Type comparison
int intA = 10, intB = 10;
print compare(intA, intB) "\n"
print compare(7, 7) "\n"
So what we implemented above pretty much does, that the ::==(_xx, _xx) function does. A simple content comparison (pretty much treat the variable it like an integer). Hope this clarifies things, sorry for going off topic. Regards, Mathias
|
|
Re: Attribute Compare DXL llandale - Thu Oct 24 14:26:43 EDT 2013 Mathias Mamsch - Thu Oct 24 11:47:15 EDT 2013
The third one is actually the one that compares anything else (as long as the datatype is the same on the left side). In DXL if you use those underscore types the order in which you define functions actually matters. The ones that you declare last take precedence over the ones you declare first. You can use this to create functions that work on any type, but have special implementations for certain types.
Note that the underscore types stand for any type, but if you use the same underscore type in a function
/*
bool compare (_x A, _y B) {
print "You can compare variables with different types:"
return (A int == B int )}
*/
bool compare (_xx A, _xx B) {
print "You can only compare variables of the same type:"
return (A int == B int )
}
bool compare (int A, int B) {
print "Special integer comparison (Note: nothing equals 7):"
return (A == B) && A != 7
}
Folder fldA = folder "/"; Folder fldB = null; Folder fldC = folder "/";
Project p = project "/";
print compare(fldA, fldB) "\n"
print compare(fldA, fldC) "\n"
// print compare(fldA, p) "\n" // does not work with Same Type comparison
int intA = 10, intB = 10;
print compare(intA, intB) "\n"
print compare(7, 7) "\n"
So what we implemented above pretty much does, that the ::==(_xx, _xx) function does. A simple content comparison (pretty much treat the variable it like an integer). Hope this clarifies things, sorry for going off topic. Regards, Mathias
You seem to be having some success draging me, kicking and screaming, into your underworld.
So, "yes"? the generic "::==" perm compares the address whereas the specific ones usually compare the contents?
-Louie
|
|
Re: Attribute Compare DXL oaklodge - Fri Oct 25 02:49:39 EDT 2013 llandale - Thu Oct 24 14:26:43 EDT 2013
You seem to be having some success draging me, kicking and screaming, into your underworld.
So, "yes"? the generic "::==" perm compares the address whereas the specific ones usually compare the contents?
-Louie
Try working with him... ;)
|
|