Hi,
I have found some unexpected behaviour with the atr_add2ent procedure. Although the attribute is added with the correct name. It appears that the name in the attrib variable can be bmodified by atr_add2ent (and presumably also other atr_add procedures).
Below is an extract of my DCAL code that uses atr_add2ent:
I've added notes about the results in the comments above, but basically atr.name was set to an invalid 13 character value by the atr_add2ent call. The macro was crashing with 'string too long' errors in subsequent logic, and it took me much time to find the cause (I don't normally add quite so many logging calls!).
Posting this information in case it saves somebody else the angst that it caused me. I have aslo added some notes regarding this to my version of the DCAL Manual (http://www.dhsoftware.com.au/DCAL.pdf).
Rgds,
David H
I have found some unexpected behaviour with the atr_add2ent procedure. Although the attribute is added with the correct name. It appears that the name in the attrib variable can be bmodified by atr_add2ent (and presumably also other atr_add procedures).
Below is an extract of my DCAL code that uses atr_add2ent:
Code: Select all
strassign (atr.name, tag);
LogStrStr ('Tag assigned', atr.name); ! LogStrStr is my procedure and writes 2 string values to a file
atr.str := 'dhSpacePlannerTag_';
AppendDateTimeStamp (atr.str, true, true, false, false, true);
LogStrStr ('About to add tag', atr.name); !atr.name has the expected 12 character name at this point
atr_add2ent (ent, atr);
LogStrStr ('Tag added', atr.name); !atr.name appears to have a space appended to it
LogStrInt ('Tag added', strlen(atr.name)); !strlen(atr.name) returns 13 (LogStrInt is my procedure and writes a string and an integer string to a file)
if atr_entfind (ent, tag, atr) then
LogStrStr ('Tag retrieved', atr.name); !the attribute has been added to the entity correctly, and is retrieved with the correct 12 character name
end;
I've added notes about the results in the comments above, but basically atr.name was set to an invalid 13 character value by the atr_add2ent call. The macro was crashing with 'string too long' errors in subsequent logic, and it took me much time to find the cause (I don't normally add quite so many logging calls!).
Posting this information in case it saves somebody else the angst that it caused me. I have aslo added some notes regarding this to my version of the DCAL Manual (http://www.dhsoftware.com.au/DCAL.pdf).
Rgds,
David H
David Henderson
dhSoftware - Add-on Macros for DataCAD
dhSoftware - Add-on Macros for DataCAD