09-10-2009 09:36 AM
Today a very powerful and flexible function, Type Cast. One of the most forgiving functions around, it will happily take anything you throw at it and give you a result. If you aren't careful, it may not be the result you are looking for. I use this one a lot when I read a binary data file created in another language and need to tell LV its type. After you read the help, you should know the results you get in the following cases:
Note: When you copy a BD image, coercion dots don't seem to be included.
If you want to see more unexpected Type Cast results, check this out.
http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=45&query.id=1122782#M45
VIOTD groundrules here.
09-10-2009 09:41 AM
Darin.K wrote:Today a very powerful and flexible function, Type Cast. One of the most forgiving functions around,...
Hmmm... forgiving?
The type cast is the only(?) node in LV that will let you write code that will crash LV.
It should be used with caution.
Ben
09-10-2009 09:45 AM
09-10-2009 10:24 AM
Ben wrote:
Darin.K wrote:Today a very powerful and flexible function, Type Cast. One of the most forgiving functions around,...
Hmmm... forgiving?
The type cast is the only(?) node in LV that will let you write code that will crash LV.
It should be used with caution.
Ben
I say forgiving since it will let you connect pretty much anything to any terminal and dutifully perform its job. But it does bear repeating, caveat type caster.
I have seen plenty of craziness, but I have never managed to crash LV with a Type Cast, any examples? (To be avoided of course).
09-10-2009 10:26 AM
Typecast has always been a favorite for obfuscated LabVIEW code.
Some examples:
Create text from booleans: HelloWorldJP.vi by JeanPierre (posted here)
... or from a bunch of zeros and NaNs: HelloWorld02a.vi (posted here)
There are plenty more in that thread.... 😄
09-10-2009 10:32 AM
How to crash LV in a bunch of steps;
Create a queue ref to pass a cluster of some type.
Type cast the queue ref as a queue ref for a different type of cluster.
Pass that (now bogus) ref to another VI to dequeue data.
In my case the data was actually passed but when came to ime for LV to deallocate the buffer, the dereferencing tried to deref a buffer ofa type other than what was in it and.. crash.
I need support to figure out what I had done wrong and boy was I embarased.
Ben
09-10-2009 01:13 PM
Ben wrote:How to crash LV in a bunch of steps;
Reminds me of a (recurring) story from my grad school days. I would typically work into the late night/early morning to get the DAQ software working. At some point I'd start running it thinking "It's safe unless someone does A,B,C,D and E. Nobody in their right mind would do that". I'd go home to sleep and inevitably the phone would ring a few hours later and it would be my advisor.
"The DAQ crashed"
"What were you doing when it crashed?"
"I just did A,B,C,D then E"
"I'll be in to fix it soon..."
My advisor always had the magic touch in the lab, I called him "sh&t-finger" (after I finished my thesis)
Now I can imagine some NI engineer thinking, LV is pretty stable unless someone does "A,B,C,D and E and nobody would do that"
Phone rings, "Hi this is Ben...."
(Don't worry, you're still goldfinger in my book). If you ain't crashin' LabVIEW, you ain't tryin.
09-11-2009 03:46 PM
Altenbach,
I like the obfuscated code links from years ago, pretty interesting stuff. However I am COMPLETELY stumped on how the boolean one works. Want to spill the secret?
09-11-2009 03:53 PM
A beautiful explanation further down the thread.
09-11-2009 04:23 PM