Recursion in Labview

Is there any straightforward way to do general recursion in Labview?
Every other programming language I've ever seen supports
recursion.  I don't want to have to build a stack to push and pop
contexts, which will obviously be unique for each implementation of
recursion.
Is recursion supported in Labview 8?
Scott

Hi Scott
You can do recursion using the vi-server.
Have a look at this thread: http://forums.ni.com/ni/board/message?board.id=170&message.id=111223&query.id=0#M111223. There I posted a vi to read the elements of a tree-structure using recursion.
Hope this helps.
Thomas
Using LV8.0
Don't be afraid to rate a good answer...

Similar Messages

  • How to cache VI ref in recursive chain?

    I am writing a recursive VI - a VI that calls itself.
    The VI generates an image by recursively subdividing the image rectangle until it finds a rectangle small enough to work on.
    (It's a mandelbrot image generator, if you must know... :-)
    It calls itself by opening a VI reference to itself (using OPEN VI REFERENCE), calling that via CALL BY REF, and then closing the reference.
    These calls might get to a level of 20 or 25 deep.
    It works. 100 %.
    In thinking that I could speed it up a bit, I tried to cache the VI reference. I was thinking that each OPEN VI REF was having to do a whole bunch of stuff. If I could just open the reference once, and store it, then I wouldn't have to do all that stuff every time.
    So I tried that. I opened the reference ONCE, and stored it in a global variable. When I need to recursively call myself, I used that reference.
    No Go.
    The recursive call returns an error message:
    Error 1042 occurred at Call By Reference Node
    in Calc Mandel Rectangle.vi
    ->Calc Mandel Rectangle.vi
    ->Get Mandelbrot Image.vi
    ->Mandelbrot Test.vi
    Possible reason(s):
    LabVIEW: Attempted recursive call.
    Notice that the error occurs on the SECOND level down, not the first.
    My hypothesis is that a ref to a VI running at level 1 is DIFFERENT from a ref to the same VI called from itself (running at level 2).
    I compared the global ref to a local one, and it said they were different.
    When you generate the ref each time, it accounts for this, but when you stash the ref before the first call, it is only valid for the first level.
    I have tried opening the reference with OPTIONS = 8, which is supposed to mean prepare for recursive call, but that makes no difference.
    I'm on LV7.1, OS X.
    QUESTIONS:
    1... Is there a way to stash a VI ref so that it applies to any level?
    2... Does the OPEN VI REF function take enough time to worry about?
    3... Is there something I am missing in this approach?
    Message Edited by CoastalMaineBird on 01-24-2006 12:36 PM
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    1. No. each level of recursion must open a separate VI reference to work with a new instance of the VI.
    OK, that's what I surmised by observation. Since the error message came from TWO levels deep, it seems that the first level was OK, but it choked when trying to go deeper.
    2. The VI is already in memory so the time penalty is less severe to reinstanciate it than to open it from file.
    This is true if you DO NOT CLOSE it. Normally I'm in the habit of closing the ref when I'm done with it. In this case, I would subdivide a rectangle into 4 quadrants, open a ref, call myself 4 times, and close the ref. If I omit the CLOSE part, the time penalty is substantially reduced (probably because the next OPEN REF re-uses the same info).
    However if you recursively call the VI in a loop, you can open a VI reference outside the loop and reuse it in the the loop, closing it afterwards outside the loop.
    Yes, I was doing that. But the CLOSE function apparently causes the next OPEN REF to have to do all the work over again.
    Usually when the user doesn't notice, I don't worry about time optimization.
    Sensible, but when a C version produces a picture in about 1/100 the time, I would call that noticable. And I am trying to produce a QuickTime movie of these images, so I'd like to generate them as fast as possible.
    3. Recursion in LabVIEW is not very efficient.
    I am coming to realize that. I have used it to delete a disk folder hierarchy, and to traverse a VI and its children, and its children's children, etc., but I wasn't concerned with speed in either case. Now I am.
    There is always a way to code your VI in such a way that it doesn't use recursion by building a data stack (data for each level in an array stored in a shift register of your loop).
    I will look into that. This project was intended to introduce my apprentice programmer to the idea of recursion, and it's an elegant use of it in theory. However in practice, it's dog slow.
    Thanks for your thoughts.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • How to read all the files in the directory

    Hi,
    I want to read all the files from a directory and perform some operations on them. How to read one file at a time from the directory. Is there any operation like the * sign in Dos and Matlab. Is there any such vi which does that.
    Thanks,
    Nitin

    I'm glad I could help, Danny.  Using the VI Server technique for recursion is very slow and memory-intensive.  I have never seen a need for recursion in LabVIEW that couldn't be solved with a loop and shift registers.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Using C+ Function "QSORT" in LV

    Hi all,
    I'm converting some C+ code to LabVIEW. 
    I want to use the C+ "QSORT" function as I cannot find an equivalent in LV.  Is there one?
    Can I use the Code Interface Node?  I don't have a C compiler.  I don't know how to write a C file.
    Here is a description of the QSORT function taken from the Using External Code in LV manual (p276):
    QSortvoid QSort(arrayp, n, elmtSize, compareProcP());PurposeSorts an array of an arbitrary data type using the QuickSort algorithm. In addition to passing
    the array you want to sort to this routine, you also pass a comparison procedure that this sort
    routine then uses to compare elements in the array.The comparison routine should return a number less than zero if a is less than b, zero if a is equal to b, and a number greater than zero if a is greater than b.
    You should declare the comparison routine to have the following parameters and return type.
    int32 compareProcP(UPtr a, UPtr b);ParametersName Type Description
    arrayp Uptr Pointer to an array of data.n int32 Number of elements in the array you want to sort.elmtSize int32 Size in bytes of an array element.compareProcP CompareProcPtr Comparison routine you want QSort to useto compare array elements. QSort passes this routine the addresses of two elements
    that it needs to compare.

    I found a couple of QUICK SORT LV implementations.
    They appear to work for simple numeric arrays but I cannot get them to work for my application.  I'm trying to implement the Graham's (Hull) Algorithm (see here).
    Attached are a couple of the implementations.  I got them from here and another place.
    I'm trying to sort cluster array.  My Compare function compares 3 (not 2) array elements.  It appears to sort some of my array correctly but may be terminating early.  The attached implementations call only 2 instances of QSORT recursively.. do I need more?..
    Message Edited by battler. on 05-22-2010 09:24 PM
    Attachments:
    Recursion-in-LabVIEW-Examples.zip ‏134 KB
    lvqsort-0.1.zip ‏37 KB

  • Error 7 occurred at Create Folder in Create Directory Recursive.vi-

    Recieved following message when attemoting to create source distribution
    Error 7 occurred at Create Folder in Create Directory Recursive.vi->ABAPI Dist Create Directory Recursive.vi->ABAPI Dist Chk for Destinations.vi->ABAPI Copy Files and Apply Settings.vi->SDBEP_Invoke_Build_Engine.vi->SDBUIP_Build_Invoke.vi->SDBUIP_Build_Rule_Editor.vi->SDBUIP_Item_OnDoProperties.vi->SDBUIP_Item_OnDoProperties.vi.ProxyCaller
    Possible reason(s):
    LabVIEW:  File not found. The file might have been moved or deleted, or the file path might be incorrectly formatted for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux.

    Hello,
    Could you please list which options you are selecting when building a
    source distribution (I am assuming you are using LabVIEW 8.0?).
    Do you get this error when clicking on "Generate Preview" button when configuring source distribution properties?
    Under "Distribution Settings" category, could you try checking the
    "Disconnect type definitions and remove unuses polymorphic VI
    instances" option and see if that helps with the build process?
    Also I suggest Mass Compiling your VIs (Tools -> Advanced -> Mass Compile) before creating a source distribution.
    If these do not help, could you attach your project with all the VIs it contains here?
    Thank you and best regards,
    Shakhina P.
    Applications Engineer
    National Instruments

  • Nested Classes in Labview 8.2

    hello everyone,
    I am a 'measurement studio' convert to labview, so I have been getting my head around the 'object oriented programming' features of labview 8.2. There seems to be many things lacking in this implementation, like Java/C# style interfaces, and abstract classes.
    Also I haven't found a way to create a nested class (so a class within a class). Is this possible in Labview 8.2 or 8.5?
    Thanks,
    paul

    I just stumbled across this post looking for other information......
    Is it true that nested classes are not supported?
    I just tried this out and it seemed to work for me.  Can we add a class as a data member of another class?  I think I recall this even being propagated in an article, but I can't remember which.
    I think it was about an object referencing itself in it's own data field to create a recursive object call.....
    Can someone please confirm that nested classes are supported and working?  Which caveats need to be observed?  I'm just starting working on something which kind of relies on the ability to nest classes, so I'm quite interested as to whether it's feasible or not.
    I'm using LV 8.2.1.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • How to know the advance of the copy and paste directory in LabVIEW?

    Hello,
    I am ussing the "copy vi " to copy a windows directory in a different location and works vey well, but I would like to show to the application user the advance amount of the directory copy performed by my LabVIEW 8.2 application,  as windows do (or better because normally windows is not accurate in the remaining time).
    Does any body know how to do it?
    Any help will be welcome
    AJJR

    You basically have to do this yourself. You would need to first get a count of the files so you can accurately determine your current progress. The Recursive File List VI can give you a total number of files. Then you can use a progress bar to show the progress. Do a search on the forum for "progress bar". Examples have been posted over the years.

  • Test coverage in LabView Unit Test Framework

    Hi,
    can somebody from NI confirm the following two statements about the Unit Test Framework:
    1. The framework does not support "recursive coverage metrics", where the coverage considers sub-VIs that are executed in the VI under test.
    2. 100% coverage means something weaker that common "branch coverage". For example, an "if" VI is a branch in the program but it is not considered as a branch by LabView's test coverage metrics.
    Thanks,
    Peter

    Hello Johannes,
    I'm interested in branch coverage of a VI under test.
    Imagine a VI A that calls another VI B. If A is tested and LV's unit test framework reports 100% test coverage for A, it is possible that the test cases didn't visit all frames (branches) in B.
    Now my question is: is it possible that LV thinks of A as "flattened" so that all code in B is considered as code of A?
    Peter

  • Algorithm an data Structure in Labview

    Hello,
    I want to learn implementing algorithm and data stucture using LabVIEW. Is there a book or link some of you may recommend?
    thanks

    Aristocrate wrote:
    you're right altenbach1
    however most labview tutorial only teach you how to program with labview; the basics. But none elaborate on how to implement complex data structre like Queues, list, threes, or recursion. That is actually what I want. Same like we observe with other text books for c,c++ and java.
    That's probably because LabVIEW does some of these for you.  I remember learning the different sort algorithms and how to implement them with trees and other methods.  It was all good for academics, but when it came to the real world just use the built in sort function.  Same with queues.
    If you are sick of the beginner LabVIEW stuff I suggest going to a local user group to try to learn from others.  These generally are an intermediate step after you've master the beginner stuff.  There are official coarses that go beyond beginner stuff, but they too likely won't focus on algorithms.  More often these coarses explain how to make large scale applications, or how to design an application to scale up without painting your self into a corner.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Labview resizing control.....

    Hello All,
    I am in the middle of developing an application that will be bundled with our product.  I have developed many such applications using visual studio, however this is my first adventure using Labview.
    As many of you know, one of the most common variables in distributing an application is the und-user screen resolution.  With the relatively recent explosion of differing screen resolutions and aspect ratios, making applications resolution independent is even more important than ever.  Along with this, giving the customer the ability to resize the appliction at will is a huge benefit.  On many occasions I have walked into a customer's site to see my application shrunk down to a corner of the window, where the use can still see it, almost like an indicator.
    For visual studio, I had purchased a third party control.  Plunk the control onto the window (it became invisible at run time) and all of the controls, fonts, etc resized as the screen was resized.  When visual studio went to .Net, this particular control no longer worked.  I had to evaluate 5 different controls to get one that even came close to working properly, and even then I had to work with support and beta test many versions of that control to get the bugs out. 
    Now I know that Labview has the panel resize options, etc and I have played around with them.  However, as most of you know, many problems still exist, such as the fonts not resizing, and multiple window changes cause control distortion, even when brought back to the same panel size.
    So, what I am wondering is this:  A) Does anyone make a control that I can purchase that does a good job in this regard, or B) if not, how about opening a discussion on how to implement a control to do just this?
    If I need to, as I forsee doing more applications with Labview, I could tackle this on my own, but as I am new to LV my learning curve may be steep so I'd like to draw on the abundance of talent and experience I've read on this board.
    I was thinking of a control that would enumerate all of the controls, labels, etc on the panel.  During the development cycle it would store all of the control / font sizes (internally? to a file?) as the developer intended the panel to appear.  At execution time (after it is built) each time the panel is resized, the control would set the height/widths and font sizes as needed.  Why store the development time sizes?  To eliminate the errors that creep up when sizing the panel up and down multiple times.  I assume this occurs in LV since original size is not tracked and pixel displacement is non-uniform across the pane, and the moving / scaling is non-integer in nature but gets applied to integer properties.  For example, when resizing from the lower right corner, to say half the width / height, controls in that corner move ALOT while controls in the Upper-left only move slightly, yet all controls are scaled in size the same amount.
    I would love it if someone could dope-slap me upside the head and say "just do this".  If not, what are some of the methods I should be looking at, and pitfalls to avoid?
    Thanks for your input!  

    tartan5 wrote:
    Wouldn't life be grand if every control included a set of read-only properties, say XOrigin, YOrigin, XSize, and YSize that were updated as you move the component around during development, but was fixed as you run the compiled program.  This would at least give you an absolute reference to use as you resize the panel, and eliminate the truncation errors we now see.
    You could do that using tags if that is what is needed.
    One interesting control I tested actually increased performance by grabbing an image of the window when the resize handle was moved, placing the image over the window, resizing the image as the corner was dragged.  Then when the corner was released, updated all of the controls / fonts as required, then hid the image.  It actually worked amazing well vs resizing the controls in real-time.......That might be very do-able in labview, show a picturebox, have it size to the window, etc....
    It probably would not be needed. You can just defer the panel updates until after you're done with your resizing. I was thinking the performance issue would be in going over all the controls and changing their size, but there is probably not going to be one.
    On another note, is it possible to recurse through an xcontrol and get all of the components at run time?  I have just finished developing my first xcontrol (so it's fresh on my mind) but I'm not sure how the xcontrol is viewed by the environment (ie if all the sub-components can be reference / obtained)?
    No idea. I use LV 7.0, which does not have them. My guess would be that you can't, at least in the earlier versions. Maybe the newer ones allow this, but I would doubt that. You might need to write a resize method (or ability or whatever they're called) for the control. That is one example of how writing a generic framework would be complicated.
    On your first point, are you suggesting that the resizer control would add the tags to each enumerated control itself?  That's almost as good as my wish above (LOL)....
    Well, I wouldn't call it a control. It would be a special resize handling (TM) process, but yes, that is exactly what I'm suggesting. See attached for a simple example.
    P.S. No, I don't know how to access these in LV 8.x.
    Try to take over the world!
    Attachments:
    Pos Tags.vi ‏36 KB

  • Multi-lang​uages labview applicatio​n

    Hi,
    Is it possible with labview to do a multi-languages application?
    I want the user to be able to select language in the execution menu, then,
    it will translate all label with languages information from a configuration
    file.
    I know haw to use configuration file, but i don't know how to change all
    label easily.
    Can anyone help me?
    Regards,
    Jean-Michel.

    Hi,
    "jm" wrote in message
    news:3e2e75cc$0$226$[email protected]..
    > Hi,
    >
    > Is it possible with labview to do a multi-languages application?
    > I want the user to be able to select language in the execution menu, then,
    > it will translate all label with languages information from a
    configuration
    > file.
    >
    > I know haw to use configuration file, but i don't know how to change all
    > label easily.
    The easiest way is to make a recursive vi. This vi would read a
    configuration key, e.g. viname.tabname.clustername.controlname= "some text".
    The recursive vi must look for the viname. Then it should get all objects,
    and find a refernce to the tabname. Then it should find all names (on the
    tab) again, and find the clustername. Then it should find all name
    s (in the
    cluster) and find the control name.
    In pseudo code:
    for all keys in the section of the selected language:
    ref= vi ref of the first name
    while there are names in the key
    get all controls that are in ref
    find the ref with the proper name
    endwhile
    set the name of the reference to the name in the key
    endfor
    Regards,
    Wiebe.
    > Can anyone help me?
    >
    > Regards,
    > Jean-Michel.
    >
    >

  • Recursive calculation on arrays

    I have a 3x10 input array.
    I take row 0, apply a high pass filter, take the log, and then plot it.
    Second round I have another 3x10 array, and apply the same thing on row 0. (all running in a while loop)recursiv
    So my plot would have 20 points, from row 0 (eventually I would do this for all 3 rows)
    Is this different from if I pass it in a 3x20 array at once, and do the processing and then plot it?
    Or is there a way I can save the plotted value on the graph, and just add the new result at the end?
    I am trying to avoid saving all values, so I dont want to use the 3x20 array. I want to do the calculations on 3x10 chunks of data while getting the same results.
    Thanks!!!!!!!!!

    You seem to love the word "recursive" in all your questions, but I don't think it makes sense the way you use it. If the calculations are independent (sometimes they are not!), it does not matter if you do the calculations all at once or piecewise.
    A 2x10 array is tiny. What is your actual concern?
    Your description is very fuzzy. If you want to save historic values inside a graph, you should use a chart instead. Does this have anything to do with your earlier question?
    LabVIEW Champion . Do more with less code and in less time .

  • Recursive file list pattern

    Hello,
    I have created a subvi that searches through a main folder for specific files and adds them to a compressed folder. I have 4 folders I need to create for different types of collected files (.csv and .txt). The naming convention of the files include a subject identifier, task description, and time stamp (most of the time). Here are a few examples:
    ABC_30s_narrow_ec_12-23-42-PM_R.csv (multiple with different time stamps)
    ABC_30s_narrow_ec_12-23-42-PM_L.csv (multiple with different time stamps)
    ABC_sts_arms_12-21-06-PM.csv (multiple with different time stamps)
    ABC_Tablet_2_12-26-56-PM.txt (multiple with different time stamps)
    ABC_gait.txt
    ABC_zero.csv
    I have tried using the pattern input of the Recursive File List vi to search for a specific task (e.g. 30s) and move that to a specified compressed folder (e.g. balance). The files are only moved if the "pattern" at the end of the filename. Does the pattern only match the end of the files listed or can I get it to search for the pattern in the middle of the name? And is it possible to search for two patterns (e.g. 30s and zero) and move them to the same folder, without overwriting the compressed file? I would like to figure this out without changing the naming convention too much (predetermined by somebody else).
    Thanks in advance,
    Anton
    Solved!
    Go to Solution.
    Attachments:
    example.png ‏633 KB

    The OpenG List Directory Recursive does support searching on multiple patterns.  Otherwise yeah just use the native function multiple times.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How can i get the "Do recursive listing.vi" with teh sub-vi, because my is lost???

    How can i get the "Do recursive listing.vi" with the sub-vi, because my is lost???
    THX

    I think you must be using LV 8.x...
    Do a LabVIEW repair to get it back or else, use the attached one.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Recursive File List.vi ‏33 KB

  • Event Callback from a Reentrant VI Recursion Error

    Greetings,
    I am using Register Event Callback with an ActiveX object to respond to user mouse events. The problem is that when I run the VI (the main, calling vi) as reentrant, Labview gives an error that the "Callback.vi" is attempting to recursively call "Main.vi".
    Is there a way around this problem? I intend to run two copies of "Main.vi", so reentrant execution seems necessary.
    - Colin Holbrook

    Hi Colin,
    Are you placing the Register Event Callback inside of the Main VI and then wiring the same Main VI to the VI Reference terminal?  If so, then that explains why you are getting an error.  You cannot use the Register Event Callback to call a VI within itself.  If this is not the case, then please post a simple VI that demonstrates the problem. 

Maybe you are looking for

  • I tunes and comp not reading my ipod

    All of a sudden my ipod is not being read by comp or i tunes. Dont think its my drive cause it reads hubbys ipod. Ipod charges but doesnt show up. what do i do. Thanks Cin

  • Failed process not in SXMB_MONI_BPE list

    Hi, I'm on Pi7.1 and have a BPM monitoring related problem: In SXMB_MONI I can see, that my process was aborted due to a faild send action (target system not reachable). When I invoke SXMB_MONI_BPE the process instance is not contained in the list of

  • How to print a company logo on top right corner in pdf

    Hello together, how can I print a company logo in a PDF-Document (Print Version; 0Analysis_Pattern_Export) on the top right corner. I created a own web template which just contains the company logo and included this template in the ZAnalysis_Pattern_

  • Not able to see specific tags for FSCM Credit Management on BP master data screen

    Hi All, I have already set up Collections & Dispute Management, I am now on my way to start FSCM Credit Management setting up. I have already created the BP role (UKM000) and assigned it for direction customer to BP, but I am not able to see any spec

  • Mobile Development

    Now that Apex 4.1 is out, I see that the statement of direction has been updated to indicate that the next version 4.2 will have better support for declarative, mobile development. Clearly there are many considerations involved in developing and depl