History example program doesn't work!

Dears,

I'm experiencing now with history data.
But I don't know why, the official example doesn't work!!!

History example program 
// history DXL Example 
/*
  Example history DXL program.
  Generate a report of the current Module's
  history.
*/ 
// print a brief report of the history record 
void print(History h) {
    HistoryType ht = h.type 
    print h.author "\t" h.date "\t" ht "\t" 
    if (ht == createType ||
        ht == modifyType ||
        ht == deleteType)  { // attribute type
        print h.typeName
    } else if (ht == createAttr ||
               ht == modifyAttr ||
               ht == deleteAttr)  {  
      // attribute definition
      print h.attrName 
    } else if (ht == createObject ||
               ht == clipCopyObject  ||
               ht == modifyObject) { // object
        print h.absNo 
        if (ht==modifyObject) { 
        // means an attribute has changed 
            string oldV = h.oldValue 
            string newV = h.newValue 
           print " (" h.attrName ":" oldV " -> "
                 newV ")"
        }
    }
    print "\n"
} 
// Main program 
History h 
print "All history\n\n" 
for h in current Module do print h 
print "\nHistory for current Object\n\n" 
for h in current Object do print h 
print "\nNon object history\n\n" 
for h in top current Module do print h

 


It seems to not have the property "attrName". I got always error with that.
I'm totally confused... and frustrated about it.

Even the simple code doesn't work:

 

 

Object s
History h
for h in s do {
    print h.attrName
}



The other properties seem to work, like "author", "date", "typeName", etc...

Thank You in advance,
vasgyuszi



 


vasgyuszi - Tue Apr 12 04:48:41 EDT 2011

Re: History example program doesn't work!
vasgyuszi - Tue Apr 12 11:48:45 EDT 2011

That's great. I have two dxl scripts. Both run error-free as separate scrpits. But, if I copy the smaller one into the bigger one, I get always this errors:

-E- DXL: <Line:353> incorrect arguments for (.)
-E- DXL: <Line:353> incorrectly concatenated tokens
-I- DXL: all done with 2 errors and 0 warnings

The mentioned line contains:

print  "\tattribute " h.attrName " from '" oldVal "' to '" newVal "'\n"

 


I really don't know what happens there...

Any hints would be appreciated,
vasgyuszi

 

Re: History example program doesn't work!
SystemAdmin - Tue Apr 12 12:03:14 EDT 2011

vasgyuszi - Tue Apr 12 11:48:45 EDT 2011

That's great. I have two dxl scripts. Both run error-free as separate scrpits. But, if I copy the smaller one into the bigger one, I get always this errors:

-E- DXL: <Line:353> incorrect arguments for (.)
-E- DXL: <Line:353> incorrectly concatenated tokens
-I- DXL: all done with 2 errors and 0 warnings

The mentioned line contains:

print  "\tattribute " h.attrName " from '" oldVal "' to '" newVal "'\n"

 


I really don't know what happens there...

Any hints would be appreciated,
vasgyuszi

 

A guess: one of your scripts has already a definition for attrName, probably something like "string attrName".

Re: History example program doesn't work!
Mathias Mamsch - Tue Apr 12 12:07:15 EDT 2011

vasgyuszi - Tue Apr 12 11:48:45 EDT 2011

That's great. I have two dxl scripts. Both run error-free as separate scrpits. But, if I copy the smaller one into the bigger one, I get always this errors:

-E- DXL: <Line:353> incorrect arguments for (.)
-E- DXL: <Line:353> incorrectly concatenated tokens
-I- DXL: all done with 2 errors and 0 warnings

The mentioned line contains:

print  "\tattribute " h.attrName " from '" oldVal "' to '" newVal "'\n"

 


I really don't know what happens there...

Any hints would be appreciated,
vasgyuszi

 

You are getting this error, because in some include you defined a attrName(...) function, which shadows the attrName() function that you are using. The error will probably go away, when you write:
 

print  "\tattribute " ( h.attrName() )  " from '" oldVal "' to '" newVal "'\n"

 


but I strongly suggest you give that attrName function another name, whereever it is. You need to avoid naming functions like functions in the top level context, that take no parameters. Defining another function like this (even if it has different parameters) will block access to the original function and give you that warning.

If you cannot change the library and the () approach does not work, and you cannot change the library, but you need the library, you can also patch your DXL program by hooking the affected function before the includes:

 

 

 

HAString_ oldattrName () { return attrName() }
 
#include <bad_include_that_defines_attrName.inc>
 
print  "\tattribute " ( h.oldattrName )  " from '" oldVal "' to '" newVal "'\n"
...



Regarding you earlier mentioned problem with attrName - can you post the error message? Or was it the one you mentioned in your second post? Hope this made not to much additional confusion, but cleared things up a bit ;-) Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: History example program doesn't work!
vasgyuszi - Tue Apr 12 16:02:47 EDT 2011

SystemAdmin - Tue Apr 12 12:03:14 EDT 2011
A guess: one of your scripts has already a definition for attrName, probably something like "string attrName".

Waaaaa, that's hurts...

Thank you guys! What a rookie failure... I had within the function, I implemented this little routine, at much earlier place this variable as string defined, but not used any more and forgot about simply...

Thanks again,
vasgyuszi

Re: History example program doesn't work!
vasgyuszi - Tue Apr 12 16:05:30 EDT 2011

Mathias Mamsch - Tue Apr 12 12:07:15 EDT 2011

You are getting this error, because in some include you defined a attrName(...) function, which shadows the attrName() function that you are using. The error will probably go away, when you write:
 

print  "\tattribute " ( h.attrName() )  " from '" oldVal "' to '" newVal "'\n"

 


but I strongly suggest you give that attrName function another name, whereever it is. You need to avoid naming functions like functions in the top level context, that take no parameters. Defining another function like this (even if it has different parameters) will block access to the original function and give you that warning.

If you cannot change the library and the () approach does not work, and you cannot change the library, but you need the library, you can also patch your DXL program by hooking the affected function before the includes:

 

 

 

HAString_ oldattrName () { return attrName() }
 
#include <bad_include_that_defines_attrName.inc>
 
print  "\tattribute " ( h.oldattrName )  " from '" oldVal "' to '" newVal "'\n"
...



Regarding you earlier mentioned problem with attrName - can you post the error message? Or was it the one you mentioned in your second post? Hope this made not to much additional confusion, but cleared things up a bit ;-) Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Of course I'm thankful to you both!