Jump to content

Jim's Unofficial XNode Coding Challenge


Recommended Posts

Here are the rules:

1) Create an XNode (not an External Node) that implements the following code, in order to get the default value of anything:

post-17-1170288652.png?width=400

2) License your VI under the BSD license.

First one to complete this challenge will get a pitcher of their favorite beer at Gingerman, this year at NI Week (and possibly have thier VI included in the OpenG Toolkit).

Cheers,

-Jim

Link to post
Share on other sites

Hmm...I know nothing of these mysterious "XNodes" of which you speak, but I can accomplish what you want with a built-in function and a hidden string constant:

post-4441-1170297298.png?width=400

There's an empty string hidden underneath the function and wired to to the required binary string input. You can wire whatever you want to the type input, and you'll get the default value of the data type as an output at the "value" terminal. Turn this thing into a Merge VI, give it a nifty icon, and voila...a "default value retriever". If you insist on an XNode (which, again, I know nothing about), you could wrap this trick up pretty nicely and just use the automatic type propogation of XNode terminals, if in fact such a thing existed...it would get rid of the hidden string constant, anyway.

I know this won't get me a pitcher of beer, but maybe a bottle of ginger ale? ;)

-D

Link to post
Share on other sites
Hmm...I know nothing of these mysterious "XNodes" of which you speak, but I can accomplish what you want with a built-in function and a hidden string constant:

post-4441-1170297298.png?width=400

There's an empty string hidden underneath the function and wired to to the required binary string input. You can wire whatever you want to the type input, and you'll get the default value of the data type as an output at the "value" terminal. Turn this thing into a Merge VI, give it a nifty icon, and voila...a "default value retriever". If you insist on an XNode (which, again, I know nothing about), you could wrap this trick up pretty nicely and just use the automatic type propogation of XNode terminals, if in fact such a thing existed...it would get rid of the hidden string constant, anyway.

I know this won't get me a pitcher of beer, but maybe a bottle of ginger ale? ;)

-D

I forgot to mention requirement #4: Can't crash LabVIEW. Maybe it's just me, but I've had so much bad luck with the Unflatten From String function (using invalid string/flattened data) that I shutter at the thought of this solution.

Your answer wins you a body shot at Coyote Ugly. And yes, there will be photos taken that will end up on the NI Week Blog, for sure. :yes:

Link to post
Share on other sites

Unflatten has been pretty stable for me in LabVIEW 8.2. But fine, here's another way, although this one is 48x48 pixels instead of 32x32:

post-4441-1170299548.png?width=400

This was my first idea, and would probably be the easiest to wrap with one of these mythical "XNodes" I keep hearing about.

-D

Link to post
Share on other sites
Here are the rules:

1) Create an XNode (not an External Node) that implements the following code, in order to get the default value of anything:

post-17-1170288652.png?width=400

2) License your VI under the BSD license.

First one to complete this challenge will get a pitcher of their favorite beer at Gingerman, this year at NI Week (and possibly have thier VI included in the OpenG Toolkit).

Cheers,

-Jim

Hi, there is my xnode. Finally it's an easy one, you don't have to do any scripting to get the default data. :thumbup:

Download File:post-223-1170317628.llb

have a nice day

Dany

Link to post
Share on other sites
1) Create an XNode (not an External Node) that implements the following code, in order to get the default value of anything:

post-17-1170288652.png?width=400

It's not an XNode, but couldn't you do this with "Variant to Data"? Wire "anything" to "type" and an empty variant constant to the variant input.

Link to post
Share on other sites
Hi, there is my xnode. Finally it's an easy one, you don't have to do any scripting to get the default data. :thumbup:

Great work, Dany! I hope you can make it to NI Week to collect your prize :)

It's not an XNode, but couldn't you do this with "Variant to Data"? Wire "anything" to "type" and an empty variant constant to the variant input.

Ned, this works but is plagued with the same issues as the Unflatten from String primitive (known to crash LabVIEW). So, you don't win the beer, but you do win a body shot at Coyote Ugly ;-)

Link to post
Share on other sites
crelf is the first to ask for the beer... you get the pitcher :thumbup:

I *knew* being proactive about beer would pay off one day - thanks Dany - I'll think of you fondly whilst drinking it!!!

Link to post
Share on other sites
I *knew* being proactive about beer would pay off one day -

Normally it pays off directly, like the next morning (this morning... felt like :headbang: ) And I promised a mate to take down his bathroom...

Ton

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.