Jump to content

Strict typedef in XNodes


Recommended Posts

Hi guys!


I'd like to have my XNode to behave differently when the input is a (strict) typedef but also differently according to the typedef path (or name) if any.


In a regular VI, this is easily done by extracting the path of the typedef: Terminal>Control>TypedefPath,

but in Xnodes it's another story!


So far I managed to get the regular type in the 'AdaptToInputs' ability (which is the common use of this ability!)

and to see if it is a typedef or not by reading the properties of the control in the 'GenerateCode' ability.


But in this last ability VI, an error occurs when I try to obtain the TypedefPath (Error 7).

This error apparently occurs in Xnodes and especially Express VIs when "one of the internal paths is hard coded incorrectly"


Is there a limitation due to the XNode or else?


I guess that I could get around the problem by scripting the owning VI and retrieve the typedef of the control connected to the XNode directly but it would be quite cumbersome and ugly.


Any thoughts on the subject?


Link to comment

I think its because your terminal on the xnode isn't really a typedef but just an adapted terminal.  Maybe try opening the typedef itself (by using the string of the actual name) and then getting the path.


So somethign like:


control -> Value-> Strip out typedef name from variant -> open vi reference (with the string name in same application ref) -> then get path.



Link to comment

Nicely done, I didn't think about extracting the type from the variant!


Based on your idea, I used GetTypedefPath.vi which is in the vi.lib folder and it works perfectly in the 'AdaptToInputs' ability without scripting the XNode reference.



UPDATE: For the challenge, I also tried to get the type of the control by following wires from the XNode

               back to the control/constant source of the type (since I didn't manage to get it from the XNode control before the solution of Jon)

                and it works also.

                It is a lot more complicated (and stupid?) but it works.

Link to comment

Thanks Jon!


Yes, debugging XNodes and figuring their behavior behind the scene can sometimes be a pain in the butt!


It is true that because of the lack of support from NI, stability of XNodes and compatibility are not guaranteed.

That said, in my case clients always require the source code but rarely modify it themselves, so I was thinking that replacing all XNodes by their generated code in the release version could be interesting...

(I would then continue the development using XNodes from my private version or replace back the generated code parts by their XNodes for the development of following releases)


If we do not use abilities like "OnFontChange", etc. (abilities that depend on the platform), it would be seamless to the user/client...

Of course it would not work if the client wants to modify also the code generated by these XNodes!

Link to comment

For the only Xnodes I created/actually used, I created a method where you could right click on the Xnode and replace the Xnode with a subVI containing whatever the xnode created.  Its really straightforward to implement, I'll try to dig it up but its been a while and I haven't been maintaining it.

Link to comment
  • 2 weeks later...
  • 3 weeks later...
  • 3 weeks later...
  • 4 weeks later...

Join the conversation

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

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.