08-17-2018 12:45 AM - edited 08-17-2018 12:48 AM
Hi prhs,
the error is due to your failure! 😄
You did not follow ALL of my suggestions as you used an I32 constant to define the datatype at the Deserialize function! In my snippet above I used a U16 and in the message I clearly mentioned to use U16 or I16…
Why didn't you just used my snippet?
08-17-2018 09:44 AM
@GerdW wrote:
Hi prhs,
the error is due to your failure! 😄
You did not follow ALL of my suggestions as you used an I32 constant to define the datatype at the Deserialize function! In my snippet above I used a U16 and in the message I clearly mentioned to use U16 or I16…
Why didn't you just used my snippet?
you're right!!! i just changed it and it worked fine. i didn't use the snippet because my computer, somehow, doesn't deal with them properly. i am using chrome but i tried explorer and when i drag it in explorer, it just gives me the name and place of the snippet whereas in chrome, i drag it onto the desktop and then into labview and it just gives me non-working picture of the thing. thanks!!!
by the way, why does the length of the number make such a difference? shouldn't it just add a bunch of zeros? probably a dumb question; but, hey, i may as well ask someone who clearly knows!
thanks!
08-18-2018 05:24 AM
@prhs wrote:
by the way, why does the length of the number make such a difference? shouldn't it just add a bunch of zeros? probably a dumb question; but, hey, i may as well ask someone who clearly knows!
thanks!
If you would do proper error handling you would see that the Unflatten from String function returns an error because the passed in byte stream (string) is to small to satisfy the requirement of the passed in datatype. The Unflatten from String (unlike the Typecast) has error terminals and therefore uses them to properly handle just about any possible error that you can cause.
A function returning an error will usually not perform any other operation and all the other terminals will normally simply return the default value for the datatype and not some intermediate wrong value.
08-18-2018 08:13 PM
@prhs wrote:
@GerdWby the way, why does the length of the number make such a difference? shouldn't it just add a bunch of zeros? probably a dumb question; but, hey, i may as well ask someone who clearly knows!
Rolf basically answered your question, but for the answer to "stick" with you, I recommend you "play scientist" (or "Test Engineer") and do a little experiment:
I suggest you put the number 1234 in the U16 Control, and before running the code, "predict" what the String should be. As you already know from doing the Unflatten first "incorrectly" and then "correctly", the (correct) U16 Out will show the input number, and the U32 Out will show 0 (always).
Go and Use Those Error Lines (they are there for good reasons)!
Bob Schor