LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Whats happening internally within the unflatten from string function?

I am getting unflatten from string error intermitently in my program. I can't post the program to get help but essentially I am storing a GOOP object reference as a string. The reference is flattened to a string and stored upon creation, at a latter time the string is then unflatterned to retrieve the reference and then the data. This works most of the time but occansionaly the unflatterned from string function fails. Prior to passing the string to the function I am checking that the string isn't null. I am assuming something else is corrupting the string prior to passing to this fucntion and would like to know what would trigger the error in the function as it may help me realise what is happening
prior.
Cheers,
Wayne
0 Kudos
Message 1 of 6
(3,108 Views)
Hi,

It really seems strange this problem, but one thing that might be the cause is how you store the flatten string. You do not mention that. I have once had problems when storing GOOP references as a sting and passing them between test VIs in TestStand using a string parameters in TestStand. A flatten string might have special chars that not all applications (such as TestStand parameters) can handle that and just trunkate the string when such a char is present, mistakenly inteprets that as end of string. Have you tried to check that string length is the same?

However to make sure you get rid of all problems with string termination, you really should cast your GOOP reference into something else. I would instead cast the reference to an U32, or
if you want, to solve the string problem for other types than GOOP reference, then flatten the type into string and then convert the string to an array of U8 before storing it. This would by sure solve your problem.

Regards,
Mattias Ericsson
Endevo
Sweden
Main developer of the new GOOP2 and GOOP Wizard 3.

PS! Have you seen that there is a new GOOP release that also may handle inheritance? Please check out: http://www.endevo.se/default.asp?lang=eng and click on "Products". There are examples, demos and white papers describing the new GOOP Inheritance Toolkit.
0 Kudos
Message 2 of 6
(3,108 Views)
Thanks Mattias you have hit the nail on the head!!
I am storing the string in the LV7 Tree Control and it can't handle six characters (hex values: 9, A, B, C, D and 20). I have contacted NI support as I have no option but to store the reference as a string (Tag Value) - I think?
Cheers,
Wayne
0 Kudos
Message 3 of 6
(3,108 Views)
Hi Wayne,

Ok, as I suspected. But there is an easy solution to your problem if you want to store your GOOP reference as a string. First cast the reference to an U32, then convert the U32 to a hex string (or if you want decimal or octal!), use the VIs in the String/Number conversion palette. Then you might store the reference as a readable string without any use of hex values: 9, A, B, C, D and 20. (I suppose you mean ascii codes). I haven't really tested this my self. If this do not work, the you could create a look-up table where you map references with a valid unique string tag that could be used to find the corresponding reference and vice verse.

Regards,

Mattias
0 Kudos
Message 4 of 6
(3,108 Views)
Thanks again Mattias - I have just tried your sugestion of casting to a U32 then convert to a readable string before storage and this is working well. It is a clean way of doing things compared to the lookup table, which was where my thoguhts were.
Cheers,
Wayne
0 Kudos
Message 5 of 6
(3,108 Views)
Hi,

I think you also could flatten the reference to an XML string (Advanced->Data Manipulation->XML) if you run LV 6.1 or later. The string does contain LF/CR but I guess that would work in most cases.

Mattias
0 Kudos
Message 6 of 6
(3,108 Views)