Norm Kirchner Posted October 13, 2006 Report Share Posted October 13, 2006 I just had one of those eureka! moments when pondering the implementation of recursive calls. I know that it does not take much effor to recurse a VI But what about a vi that automates the process for you and wraps it up into a neat little sub-vi here is my vision which I don't have time to complete but I belive that the community could easily wrap their wires around Create a VI that when dropped into a BD will do the following Create a sub-vi in the same location as the parent w/ some special namespacing drop the necessary blocks for recursion: see picture above determine the parents connector pane and set the sub-vi's pane to the same along w/ the static pane reference Copy the parents icon and do a glyph edit to mark as recursive then do a replace on the parents BD of the dropped recursion vi w/ the one just created So I belive what would happen is the parent BD would have a sub-vi which looked almost identical which allowed for recursive calls!!!! whatdaya think!!! Quote Link to comment
crelf Posted October 13, 2006 Report Share Posted October 13, 2006 That's just crazy enough to work! Quote Link to comment
Norm Kirchner Posted October 13, 2006 Author Report Share Posted October 13, 2006 I'm thinking also that we could use express technology to accomplish this because it does the creation of a sub-vi for you w/out needing to make new files. For those of you who are savvy to the express world. We have the ability to modify the source when running the configure vi. So when the express is configured (either automatically when dropped or when told so by the user) would be to modify the source VI to have the same inputs as the caller and drop the vi-server recursion fuctions in the guts. oooooh I'm liking this. Quote Link to comment
robijn Posted October 13, 2006 Report Share Posted October 13, 2006 For those of you who are savvy to the express world. We have the ability to modify the source when running the configure vi. So when the express is configured (either automatically when dropped or when told so by the user) would be to modify the source VI to have the same inputs as the caller and drop the vi-server recursion fuctions in the guts. Hey that sounds very interesting ! So you can create the correct connector pane constant ! I've been waiting for that for quite some time... Can you create such a constant given a non-typed VI ref ? Joris Quote Link to comment
PJM_labview Posted October 13, 2006 Report Share Posted October 13, 2006 I'm thinking also that we could use express technology to accomplish this because it does the creation of a sub-vi for you w/out needing to make new files. For those of you who are savvy to the express world. We have the ability to modify the source when running the configure vi. So when the express is configured (either automatically when dropped or when told so by the user) would be to modify the source VI to have the same inputs as the caller and drop the vi-server recursion fuctions in the guts. oooooh I'm liking this. I think an externalNode (XNode) will be better for that, because, as you modify the connector pane of the parent, the connector pane of the child (the recursive call subVI) should modify itself as well.Edit: Another benefit is that you would not even need to create a SubVI in your project folder. The code would be right there behind the XNode. PJM Quote Link to comment
Michael Aivaliotis Posted October 14, 2006 Report Share Posted October 14, 2006 whatdaya think!!!Sounds great! Show me the code. Quote Link to comment
Jim Kring Posted October 15, 2006 Report Share Posted October 15, 2006 I think an externalNode (XNode) will be better for that, because, as you modify the connector pane of the parent, the connector pane of the child (the recursive call subVI) should modify itself as well.Edit: Another benefit is that you would not even need to create a SubVI in your project folder. The code would be right there behind the XNode. PJM I like this idea! Quote Link to comment
Aristos Queue Posted October 15, 2006 Report Share Posted October 15, 2006 I think an externalNode (XNode) will be better for that Quick safety tip for all you who seek to peek under the skirts of LV: external nodes and XNodes are not the same thing, though they both serve the same goal. External nodes were LV R&D's first attempt at nodes that script themselves. They have issues and have been supplanted by XNodes, our second attempt. XNodes are better, in theory*. *"In theory", from the Latin "en theos" meaning "with God" or, more specifically, "assuming He Who Built The System doesn't change His mind." Quote Link to comment
Norm Kirchner Posted October 15, 2006 Author Report Share Posted October 15, 2006 Hey that sounds very interesting ! So you can create the correct connector pane constant ! I've been waiting for that for quite some time...Can you create such a constant given a non-typed VI ref ? I would find it hard to beilve that w/ all the scripting tools out there that it would be impossible... although I have not specifically tried yet. anyone.... Bueller?....Bueller?? Quote Link to comment
AdamRofer Posted October 23, 2006 Report Share Posted October 23, 2006 Bueller here. http://xnodes.lavag.org/ Click on Recursion on the upper left. I desire any and all feedback, this was a quick-as-possible venture that turned out to be quite nasty. Source code is open for all of those curious, especially since the source code directly touts my abilities as a scripter. Bonus features: - Manual construction of a constant by typedef number array (that stupid ref is *not* an object creatable by the Create Object function!) - Icon tweaking (a shadowed "R" -- which is fully customizable) - Manual internal reconstruction upon double click (if necessary, which I don't think it should be) Basically it's all that was talked about...just the code looks impossibly arbitrary because it took me a lot of trial and error to find out what LabVIEW would let me do. Now if only I could convert this VI directly into :beer: :thumbup: - Adam Rofer Quote Link to comment
Mike Ashe Posted October 23, 2006 Report Share Posted October 23, 2006 Nice idea. I think your example of factorial might take a second look. Maybe I did something simply wrong, but I built your example, exactly as shown and it returns an answer of 0. Makes sense, you keep subtracting one each time, til you get to zero, then pass out the eventual zero result and multiply. What am I missing here? Quote Link to comment
AdamRofer Posted October 23, 2006 Report Share Posted October 23, 2006 One thing I've noticed is that frames sometimes don't refresh properly, so if you have a problem finding my previously referenced item (and you've been to my documentation site before) you can simply go here: http://xnodes.lavag.org/recursion.html Nice idea. I think your example of factorial might take a second look. Maybe I did something simply wrong, but I built your example, exactly as shown and it returns an answer of 0. Makes sense, you keep subtracting one each time, til you get to zero, then pass out the eventual zero result and multiply. What am I missing here? I took the code directly from NI's example: http://zone.ni.com/devzone/cda/epd/p/id/1827 Check a few things, like if your VI is re-entrant. That needs to be the case or else my recursion thingy won't do anything but send back the default values for whatever outputs. - Adam Rofer Quote Link to comment
Mike Ashe Posted October 23, 2006 Report Share Posted October 23, 2006 I took the code directly from NI's example:http://zone.ni.com/devzone/cda/epd/p/id/1827 Check a few things, like if your VI is re-entrant. Thanks for the quick reply post. I'm low on my coffee quotient and wired the n through the True case instead of hardcoding the 1 constant. I also forgot the reentrant setting. Works like a champ now. I'm going to take it and play with a few other examples, like getting the tree of a directory path with subdirectories. I'm also thnking of trying it for some XML parsing, etc. Good Job Adam! This should be cross referenced with some of the other topics on recursion. I had posted one using VI server some while back. Your XNode does this much better. Hmmm, we need to combine this with GOOP somehow, I can see some interesting possibilities. :beer: :beer: :beer: Quote Link to comment
martin@aerodynamics Posted November 28, 2006 Report Share Posted November 28, 2006 Bueller here.http://xnodes.lavag.org/ Click on Recursion on the upper left. .... Basically it's all that was talked about...just the code looks impossibly arbitrary because it took me a lot of trial and error to find out what LabVIEW would let me do. Now if only I could convert this VI directly into :beer: :thumbup: - Adam Rofer The example works "almost" perfect Today I tried to expand the functionality (a second Input and Output) Then the wires were brocken, I tried to relink etc. etc. LabVIEW Crashed etc. etc... But Finaly I know how to do it without crashing LabVIEW and it really worked!!! After changing someting in the vi I have always to replace the Vi.. But there is a "little" work arround (add/change the menue)... But I still miss the thing with the beer... Quote Link to comment
AdamRofer Posted November 28, 2006 Report Share Posted November 28, 2006 The example works "almost" perfect Today I tried to expand the functionality (a second Input and Output)Then the wires were brocken, I tried to relink etc. etc. LabVIEW Crashed etc. etc... But Finaly I know how to do it without crashing LabVIEW and it really worked!!! After changing someting in the vi I have always to replace the Vi.. But there is a "little" work arround (add/change the menue)... But I still miss the thing with the beer... I could try adding a function on the pull-down menu that says "Relink recursive VI", if that seems to be the problem. In the mean time, try to double click on the VI, that should rebuild the internals without needing to do any fancy menu stuff. Is that what caused it to crash? As for the beer, I like beer. - Adam Quote Link to comment
martin@aerodynamics Posted November 29, 2006 Report Share Posted November 29, 2006 I could try adding a function on the pull-down menu that says "Relink recursive VI", if that seems to be the problem.In the mean time, try to double click on the VI, that should rebuild the internals without needing to do any fancy menu stuff. Is that what caused it to crash? - Adam Now it doesn't crash any more. but double click cause every time an error in the recursive vi (code was not produced correctly) sorry I have the german version... and if I then replace the recursive vi then I get always broken wires (exept one wire always stays on place) all others (input and output to the recursive vi) are brocken... Update: Now I figured out why I get broken wires: This happens if I use a connector pane on the recursive vi that has more connections than connected wires... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.