XML_TO_VARIABLE has a BUG!
Spire_Jeff
Posts: 1,917
Just a heads up. I have stumbled across an error in xml_to_variable. I am using NS 2.6 and the problem presents itself when dealing with a structure. I have not narrowed it down completely, but I was using the same code set to encode/decode 4 different structures and I was having a problem with only one structure. I have spent plenty of time verifying that I did not make a stupid little typo somewhere and I have even sent the code into tech support. The problem presents as an error code 1 = structure too small, more members in XML decode string. Switching to string_to_variable and variable_to_string makes the problem go away.
If I ever have the time, I will start to pull elements out of the structure until I figure out which one is causing the problem, but I figured I would post this and hopefully save someone a few hours of debugging.
Jeff
If I ever have the time, I will start to pull elements out of the structure until I figure out which one is causing the problem, but I figured I would post this and hopefully save someone a few hours of debugging.
Jeff
0
Comments
Edit: Third time lucky. It was a long time ago that I flagged the problem so my memory's a bit hazy, but just to clarify: the dev variables were elements of the structure I was encoding / decoding. Removing the dev elements from the structure resolved the problem. Perhaps it's an issue with decoding previously encoded structures which have one or more elements which are also structures?
The structure that I am encoding does contain a device, however I thought I removed that and still had the problem... but in the multitasking world I have to live in (read as interruptions) I may have missed the write a new file step I had my suspicions that it was the DEV tho. If you look at the XML, my guess is that the decode routine is not accounting properly for the <STRUCTURE> </STRUCTURE> tags.
Now, if we can get a tech note regarding this, the next time I'm too lazy too look through tech notes and decide to call tech support, they can laugh at me and tell me to RTFM before calling them
Jeff
--John
--John
--John
Also, be cautious of the variable_to_string function as there are problems with that as well. I created a thread a while back that discussed the problems with both. Altho, at this point, I don't remember if string_to_variable had a real problem with the implementation, or just wasn't doing what I needed.
Jeff
Am I stating the problem correctly? I want to make sure I understand.
I use xml_to_variable every time I need to save data to disk. I do this quite often. I have never had a problem, but I don't think any of my structures (that I write out) contain device definitions.
Does variable_to_xml work with a dev?
Does using string_to_variable work with a dev? Sounds like it might, but would like confirmation.
I'm sorry. to which this are you referring? There are several issues addressed in this thread.
In my experience, variable_to_xml does not return an error when encoding devs, but xml_to_variable will fail to deserialise the encoded variable. As indicated in my post above, when I ran into this, the dev in question was an element of a structure which was being serialised/deserialised, so it may be an issue with encoding/decoding structures which are an element of another structure.