Do While loop with query?

There seems to be no way to do a do-while loop without using
Cfscript.
Is there a way to place a cfquery inside cfscript?

How so?
The algorithm I'm trying to write is sort of recursive.
Basically, I have a column in a table generated like so:
Row 1: Sum of (account 1, account 2)
Row 2: Sum of (account 3, account 4)
Row 3: sum of rows 1-2
Row 4: Sum of (account 5, account 6)
Row 5: Sum of rows 3-4
So basically, I'm trying to query for all of the accounts
that make up row 5 (which in this case is ALL of the accounts). It
looks like I'm going to have to work backwards from the starting
row (5) and keep checking the rows that its composed of until I hit
some base case (no more summation rows?)

Similar Messages

  • Why writes LabVIEW only every 2 seconds the measured Value to a Excel (In a while loop with 100 ms tact)?

    Hi everybody,
    I use the myDAQ to measure speed, ampere, and voltage of a battery driven motor. (For Current measurement, i use a Sensor which outputs a 0-10 V signal). I placed all DAQ-Assitants in a while loop with a [Wait until next ms multiple] clock and set a value of 100 ms. I thougt, Labview will now write into my text file 10 times a second all values. In fact, as you can see in the attached text file, Labview only writes in a unsteady interval of 1-2 seconds a value, which is too less.
    The question: Did I do anything wrong, how can you create VI that writes you lets say 10 values a second into text file? Or is simply the DigitalMultimeter input of the myDAQ not able to sample a rate of 10 Hz? I couldn´t find any information in the specification handbook about the sample rate of the DMM?
    If anyone can help me would be great! Thanx a lot, Markus
    Attachments:
    Measure Speed+Current+Voltage into Excel.vi ‏175 KB
    Test7.txt ‏1 KB

    File I/O is not very efficient. I recommend that you do you file logging in a parallel task. Have one task do your data acquision. This task would then pass the data to be logged to the logging task via a queue. That way your file operations do not impact your data acquision. Also, express VIs are not very efficient. You would be better off accessing that directly using the DAQ VIs. The express VIs contain lots of steps that do not need to be done every time you call it such as initializing the device.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Unxepected behaviour with clusters inside of while loop with shift register

    Colleagues,
    I just would like to post here small, but important bug (I guess this is the bug), which was found by coworker today morning. Just would like to share knowledge, and probably this will save some debugging time for you...
    So, the problem that you can get wrong content of the cluster in some cases. The cluster used inside of while loop with shift register (we using this construction for functional globals), and after bundle operation you can get data, which are not expected:
    See also attached code for details (LabVIEW 8.6.1, WinXP Prof SP3).
    best regards,
    Andrey.
    PS
    Bug report already sent to NI.
    Message Edited by Andrey Dmitriev on 10-16-2008 12:30 PM
    Attachments:
    BugwithClusters.png ‏15 KB
    BugwithClusters.zip ‏10 KB

    Thanks Andrey for brining this to our attention!
    The "Show Buffer Allocations" reveals that LV is not processing the code in the right order.
    Under ideal conditions, all of the data should be manipulated using the buffer "A". But as this demo shows the data is being processed in the wrong order.
    The previously posted workaround get around this by forcing the array operation to happen first, but this resluts in two additional buffers "C" and "D" and then copy this back into "B".
    Using an "Always Copy" is another workaround that uses a seperate buffer "F" to hold the data being moved from the first cluster to the second inside "E".
    I think you won a shinny new CAR* Andrey!
    Ben
    CAR = Corrective Action Report
    Message Edited by Ben on 10-16-2008 08:05 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Cluster_Bug.PNG ‏57 KB

  • While loop in query is going under infinite loop

    Declare
    @StartDate_in date,
    @EndDate date
    Set @StartDate_in = cast('2000-01-01' as date)
    Set @EndDate = cast('2010-12-31' as date)
    declare @month int
    declare @year int
    declare @endyear int
    declare @startdate date
    set @startdate= @startdate_in
    set @month = month(@StartDate_in)
    set @year= year(@StartDate_in)
    set @endyear= year(@EndDate)
    while @year<=@endyear
    Begin
    while month(@startdate)<=12 and @year<=@endyear
    begin
    print (@year);
    print (month(@startdate));
    INSERT Into target
    ( YEAR,
    MONTH,
    MONTH_VAL,
    L_DT,
    U_DT,
    S_DT,
    E_DT
    Values
    ( datepart(yyyy,@StartDate) ,
    datepart(month,@StartDate) ,
    substring(datename(month,@StartDate),1,3),
    GETDATE(),
    GETDATE(),
    (GETDATE()-1),
    null
    set @StartDate = dateadd(month,1,@StartDate);
    set @month=1;
    end
    set @year=@year+1;
    print (@year);
    print (@month);
    end
    The query although with exit condtion given in the while loop is not ending and executing infinetly
    ddl of target
    CREATE TABLE target(
    [TIME_ID] [int] IDENTITY(1,1) NOT NULL,
    [START_DT] [date] NULL,
    [E_DT] [date] NULL,
    [L_DT] [datetime] NULL,
    [U_DT] [datetime] NULL,
    [YEAR] varchar (5) NULL,
    [MONTH] varchar(5) NULL,
    [MONTH_VAL] [varchar](5) NULL
    ) ON [PRIMARY]
    GO
    Mudassar

    Try followings:Declare
    @StartDate_in date,
    @EndDate date
    Set @StartDate_in = cast('2000-01-01' as date)
    Set @EndDate = cast('2010-12-31' as date)
    declare @month int
    declare @year int
    declare @endyear int
    declare @startdate date
    declare @innerloopyear int
    set @startdate= @startdate_in
    set @month = month(@StartDate_in)
    set @year= year(@StartDate_in)
    set @endyear= year(@EndDate)
    set @innerloopyear = @year
    while @year<=@endyear
    Begin
    while month(@startdate)<=12 and @year>=@innerloopyear
    begin
    print (@year);
    print (month(@startdate));
    INSERT Into target
    ( YEAR,
    MONTH,
    MONTH_VAL,
    L_DT,
    U_DT,
    S_DT,
    E_DT
    Values
    ( datepart(yyyy,@StartDate) ,
    datepart(month,@StartDate) ,
    substring(datename(month,@StartDate),1,3),
    GETDATE(),
    GETDATE(),
    (GETDATE()-1),
    null
    set @StartDate = dateadd(month,1,@StartDate);
    set @innerloopyear = YEAR(@startdate)
    set @month=1;
    end
    print 'hello'
    set @year=@year+1;
    --set @StartDate = DATEADD(year,1,@StartDate)set @innerloopyear = @year
    print (@year);
    print (@month);
    end
    I have formatted change in "Bold".

  • How to stop a while loop with long delay

    Hi everyone,
    I am building a simple program for turning on and off a single Bit.  The task is to turn ON the Bit for a period length T1, and OFF the Bit for a period length T2. T1 is normally different from T2, and can be controlled  by users. 
    Since T1 and T2 can be variable, they sometimes can be very long.
    If I use a Wait function inside a While loop, it needs long delay to be able to Stop the Main program.
    The same situation happens when I use Timed loop.
    Can anyone suggest me how to do this task?
    Thanks a lot. 
    Message Edited by tatuan on 04-12-2010 12:56 AM

    Here's another possibility using OpenG Wait ms:
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Stop dependant while loops with 1 button

    Hi,
    I am developing a utility that allows a user to configure up to 2 devices (both use same driver with a different board number), click initialize, which then brings up a file dialog and displays arrays for the data to be collected and some error messages for each measurement.  The user then clicks the Start/Stop button to begin collecting and logging data.  Currently i have a Wait(ms) block to allow the user to set often the measurement should be made.  Currently the Start/Stop button allows collection to be started, paused, and started again.  My problem is trying to have a master stop button that should stop all loops immediately when it is pressed.
    I tried using a global variable for the stop button, but the measurement and logging while loop doesnt stop until after the wait(ms) block times out.  Can anyone give suggestions.  If i need to restructure the VI into different loops, I can do that.  I just want to understand the right way to program something like this.
    The VIs are attached.  I removed the device specific measurement VI so that anyone can open the vis and run them to see how it works.
    Attachments:
    2Devices_withoutMeasurementVI.vi ‏112 KB
    BuildOutput.vi ‏27 KB
    stopGlobal.vi ‏5 KB

    Ok.  I had a chance to take a look at your code and I think you don't quite understand the concept of "dataflow".  Let me see if I can help.
    First of all...when I refer to your upper structure, I am referring to the first while loop, sequence structure, and subsequent while loops.  When I refer to your lower structure, I am referring to the while loop containing the event structure.  Just so we get our terminology straight.
    I believe that you are under the illusion that your upper structure contains three parallel while loops.  It does not.  It contains three SERIAL while loops.  There is dataflow dependency between the while loops.  The sequence structure requires data that is not available until the first while loop has finished executing, so the sequence structure cannot start executing until the first while loop has terminated.
    The second while loop requires inputs from the first frame of the sequence structure (which, by the way, you don't need and should get rid of...the sequence structure, I mean), so it cannot start executing until the first frame of the sequence structure has terminated.  The third while loop requires inputs from the second while loop...so, again, the third while loop cannot run until the second while loop has finished executing.
    Now, for your stop button.  You have that global stopping all three loops.  So here's what is happening in your program:
    Your program starts.  The first while loop executes in parallel with the loop which contains the event structure.
    At some point you press the "stop" button.  Both the first while loop and the loop containing the event structure finish executing.
    The first frame of your sequence structure executes.
    The second frame of your sequence structure executes.  The second while loop reads the "stop" value from the global, so it executes once and then finishes.
    The third while loop starts executing.  Again, the loop reads the "stop" value from the global, so it executes once and then finishes.
    Then your program terminates.
    You need to restructure your program, because right now it doesn't make any sense at all.  Your block diagram would benefit from some serious tidying up as well, your wiring is a mess.  I suggest you look into a state machine architecture for this program.

  • Threads in while loop with two data acq loops

    Good day, I am using two while loops to perform data acquisition from two different pieces of hardware inside a "main" while loop - a total of three while loops. I want each of the data acq loops to run as fast as possible. With this model will each data acq loop run in a separate thread or will they be running in the same thread because they are both inside the "main" while loop.
    I'm not getting the performance I would like and I'm looking at ways to optimize the execution. 
    Thanks
    John 

    I would have a loop for each of you data acquisition tasks and at least one, possibly two additional loops that will write your data to file. Let the acquisition loops collect the data as quickly as possible and simply queue it off for further processing. When these loops are in parallel LabVIEW will run them on separate threads. In addition you could have a separate loop with an event structure that could handle you UI interaction. This loop could control the overall application with respect to starting and stopping the tasks, etc. You don't really need to contain all these loops in any other loop or structure. They can all reside on the block diagram next to each other. Ideally you will create subVIs for the data acquision and data processing tasks.
    Message Edited by Mark Yedinak on 10-06-2009 04:29 PM
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Code golf: stop two while loops with guaranteed iteration ratio

    Proposal
    In the vein of the Perl tradition, I'd like to see if there's any interest in solving short programming puzzles in LabVIEW. Anyone can post a problem and define the rules for solving it.
    Here's a beginning/intermediate question to whet your "palette".
    Description
    With one user-action, how would you stop two while loops such that the ratio of their iterations is the always the same? One concrete way to visualize this situation is in taking measurements: two instruments use the same timing source to take measurements, but second divides the clock down so that it is an integer factor slower than the first. For example, if the slower instrument is four times slower, then at the end of the VI, if the slower instrument takes 100 measurements, the faster instrument has taken 400.
    Rules
    You may only use vi.lib
    You cannot include any other subVIs
    Your solution must pass for loop1 interval as low as 25 ms
    Template (attached in LabVIEW 2009)
    If folks are interested in this, then let's figure out how to make future problems better. Please post your suggestions and critiques, but only if you also post a submission ;-)
    Solved!
    Go to Solution.
    Attachments:
    Multirate Loop Code Golf.vi ‏11 KB

    Norbert_B wrote:
    a) You work with an integer factor of speed. While this matches many application areas, there are still cases where the factor has to be floating point (e.g. 2.5). Additionally, the factor might "invert", so the master loop runs slower than the slave (factor 0.5 for instance).
    It sounds like you're about to post another code golf question. If you think the problem scope is too small, you're welcome to fashion one to your taste. Thanks for volunteering :-D
    Norbert_B wrote:
    b) This example does not take into account that the hardware has to be synchronized with more accuracy than the software supplies (PXI?). If hardware synchronization is required, there are two possible ways:
    - The factor can be included in the synchronization (using PLL for instance)
    - The factor has to be software implemented by data reduction for the task running at the lower pace.
    Hrm, maybe puzzles aren't really your thing after all. You are correct: I did not define every constraint that can lead to a provable best closed-form solution, but that does not prevent people from stating their assumptions and forming creative, well-reasoned, and still correct designs. I overlooked this reading of the description and neglected to add a statement that said solvers were free to add their own conditions. I will do so in the fugure :-)
    If we choose the first of your suggestions, the VI must still retrieve the data at different rates. You can dedicate a loop for each instrument to decouple any jitter and latency introduced by their connectivity or internal operation; this adds some margin of safety when there is thread and driver contention. You can also implement a single counting loop like altenbach and forego the multiloop complexity.
    Norbert_B wrote:
    c) You don't state anything about "what happens with the data". Is this time consuming? Does it introduce additional delay in loop iterations? Is it OK to have data loss?
    I don't know -- you decide, you disclose, and you solve :-)
    In my specific situation, the measurements are time consuming and do add delay (each data "sample" is 5-20 megabytes), none can be lost, and the data must be available for others to analyze later. In addition, the amount of data is saturating the hard disk throughput. If a particular write takes too long, the instrument driver may overwrite a yet unfetched sample, which is unacceptable. I did not add these details to the problem discripton becuase they don't impact the puzzle.
    I don't want to burden people with my situation and ask them to solve my problem: I want to encourage them to bring their intuition and experience to a discussion. This is the design process at its heart: understanding why and how constraints affect your decisions. If a person states the additional conditions they've assumed, readers can learn why, and more importantly, when a Notifier might be more desirable than an Occurance or a Queue more robust than a Data Value Reference.
    The best NI-published advice for stopping multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) is laughable (and is the "solution" in my template).
    Would you care to re-approach and contribute to this puzzle? I suspect you have a lot to offer :-)

  • Reset while loop with time and button?

    I am trying to get the while loop to stop and reset with a button or if time runs out. So when I switch the button it should stop the indicator; when I switch the button back on it should reset the time and start reading data again. Likewise, when time runs out it should stop the indicator and I want to flip the switch to start a new run and reset the time again. I have attached my vi for some clearification. If you have trouble understanding please let me know and Ill try and explain more. Thanks.
    Attachments:
    reseting_time_whlloop.vi ‏70 KB

    Relient wrote:
    I know my program is not efficient at all, Im inexperienced with labview and my company needs it soon so I'm trying to get it out quick. Attached is what I have so far. It is very messy!!  However it is nearly working how we want. The producer/ consumer design is needed because I am implementing this into my other program and each loop  has a different job than the other loops. This is just a mock version as I am trying to figure out the process.
    The stop buttons aren't needed but the button labeled boolean should reset the time and stop the run. When the run is stopped I want to re-enter a 'test time' and hit the button again for a new run. I just need to be able to reset the original time... Is the producer/consumer the best way to connect while loops because it seems messy?
    Again sorry if it is hard to follow and if its not the best way to go about it; I'm doing the best with what I know. Thanks for the help.
    I realize you may need this soon but you will regret it later (or the next person to touch this code) when you need to touch it again. It is overly comnplicated, messy and not very well designed. Doing a bad job quickly is never the right answer. A little extra time spent up front to do it right can save tons more time later on.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • While loop with stop button within event structure locks up front panel.

    I am not sure if this is a bug with my program or a bug within LabVIEW.  If you believe that this is a bug with my program then I will post my program to be looked at.
    The problem I am having is there is a while loop within an event structure that fires when a particular value changes.  Once the "Activate" button is pressed the while loop within the event structure starts going with a polling frequency of 1hz (1000ms wired to the "wait till next ms multiple" vi).  There is a "Deactivate" button that is wired to the stop control of the while loop and an outter while loop that resets the event structure so that the activate button is being listened to again.
    Once inside the while loop, however, none of the button are responsive within the front panel.  The VI continues to run, and only 60% of my CPU is being consumed, but none of the button or scroll bars work.  The only way for me to terminate the program is with the "Abort" button next to the "Run" button.  If I remove the event structure so that the while loop in question runs as soon as the program starts, the front panel remains responsive.  I've inserted probes within the while loop and verified that it is not running prior to the "Activate" button being asserted, and it is running after the assertion of the "Activate" button with the expected polling frequency set by the "wait till next ms multiple" vi.
    Can anyone help?  Do I need to post my code?
    -Nic

    It is typically not a good idea to stall an event structure by placing loops inside event cases. What good is an event structure if it is not free to repond to events?
    Have a look at some alternative solutions, such as in the following link:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=224817#M224817
    LabVIEW Champion . Do more with less code and in less time .

  • Stopping a while loop with a button in cvi

    Hi people,
    I am a newbie with CVI but I have used LabView Heaps. The issue I have is I want to be able to use a toggle button or a command button to stop a while loop. I used GetCtrlVal on the toggle before the while loop. I then enter the while loop and then GetCtrlVal at the end to see if the button has been pressed. The issue I have is that once I enter the loop I am unable to press any buttons on the Panel. I would normally have put a delay in the loop but the issue is I am wanting to control a robot in "realtime", thus any delays in the program results in the robot moving further than what I wanted it to. Any ideas? If you have any suggestions that would be much appreciated thank you.

    This should be in the CVI group but...
    At the tail end of your while loop add a call to function ProcessDrawEvents():
    When your program executes in a callback function or in code that does not call RunUserInterface or GetUserEvent, LabWindows/CVI does not update the user interface. Functions that are overly time-consuming can "lock out" user interface updates. To allow LabWindows/CVI to process these updates, call ProcessDrawEvents.

  • Stop a while loop with a interrupt

    I' m using a while with a delay time of 60 seconds to perform a sub vi.
    So when I press the stop button it could take in extrem 2 minutes to stop the vi. I want to use something like an interrupt or jump order to stop the vi without waiting for the end of delay time.
    How can I create an interrupt in lab view 6.1.
    Thanks for help. bye uli

    If the delay is in the calling VI using Wait (mS), you can run a smaller delay multiple times (a while loop inside your main while loop), checking Stop between each of the smaller delays until the smaller delays add up to your bigger delay. See the attached DelayWithStopCheck.vi.
    But this technique doesn't stop the sub-VI: it just stops the loop in the main VI which will still run until the sub-VI is done. You could connect the Stop button to a global which the sub-VI checks in a loop to know if the calling VI pressed Stop.
    Attachments:
    DelayWithStopCheck.VI ‏41 KB

  • Problem using while loop with !=

    Hi, I'm a beginner and still learning the basics of Java!
    Right now, I have a problem creating a while loop to read in two values.
    This is what I have entered:
    while((input != 'a') || (input != 'b'))
           Screen.out.println("Invalid Input");
           Screen.out.println("Enter 'a' or 'b' to continue");
           input = Keybd.in.readChar();
    }    I'm trying to get a input from the user, either the character 'a' or 'b' to continue, where my next set of code would come in and if they did not enter the character 'a' or 'b', it would display the "Invalid Input" message.
    What I can't get to happen in my while loop is that when I enter 'a' or 'b' , I still get the "Invalid Input" message etc. Even when I enter any other character in, I still get the same "Invalid Input" message. I thought the " != " mean "not equal to" and the " || " means OR. What am I doing wrong??

    while((input != 'a') && (input != 'b'))The || operator evaluates to true if either operand is true. If you enter an 'a', (input != 'b') is true, so the code gets executed. Similarly, if you enter 'b', you obviously didn't enter an 'a', so your code gets executed.
    You want to execute the code only if (input != 'a') AND (input != 'b').
    ~

  • Start stop while loop with tab control

    I want to be able to start and stop a while loop by entering and leaving a tab.  I am using an event structure to do so but it doesn't seem elegant or the right way to do this.  The only way I was able to get it to kind of work is by unchecking the lock front panel box in the event structure.  I have attached a sample vi of what I have so far.
    Solved!
    Go to Solution.
    Attachments:
    Loop test.vi ‏16 KB

    The problem is that you can't even stop the program by hitting the stop button until you leave the tab, which is not a friendly user interface.
    Event structures should just handle basic user events.  Any given event case should not take a long time to run.  While you are in the diagnostics tab, your code is stuck in that while loop.  Although fixing the lock front panel allows you to do other things, the LabVIEW is just queuing up all of those other UI events (like Stop button value change) and can't handle them until the inner while loop stops and allows the outer while loop to iterate again.
    You should have a parallel while loop to handle the waveform graph.  You can use notifiers or queues or an action engine FGV (see Ben's Action Engine Nugget) to pass the starting or stopping of the waveform graph update to the parallel while loop.

  • If/than embeded in while loop with mutiple outputs

    We are a Senior Design Group who is having much troubles with LV as none of us are programers and especially unfamiliar with all that LV has to offer. 
    Here is what we are thinking that the program we need needs to look like but have no real clue as to how to implement it in LV.
    WHILE Time Elapsed < 10 seconds
      {  IF Voltage = 1 V
         THAN Output Sound File 1 and Write "1" to Excel File in "A1" and Reset Time Elapsed
         IF Voltage = 1 V again
         THAN Output Sound File 2 and Write "2" to Excel File in "A2" and Reset Time Elapsed
         IF Voltage = 1 V again (for the 50th time)
         THAN Output Sound File 50 and Write "50" to Excel File in "A50" and Reset Time Elapsed
    Once 10 seconds elapses we need to break out and start the above program again (once 1 V is reconized again), except Write to Excel File in "B1....B50"
    Thank you for any help
    Struggling Students

    See here
    http://forums.ni.com/ni/board/message?board.id=250&message.id=28912&jump=true
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe you are looking for

  • Upgrade 4S to 5 or buy New?

    Will I be able to upgrade my 4S to 5 when IOS 6 is released this fall or should I wait for the new iPhone 5 when released?

  • Engineer between Logical Model and Relational Model

    I am trying to update changes from one model to the other but there are dublicate entries generated instead of updates. The Logical Model was imported from Oracle Designer, the Relational Model was imported from data dictionary. Our rule is, that the

  • Iphone 6 stays in 3G

    I traded in my iphone 5 for an iphone 6.  My new iphone 6 remains in 3G.  I have tried everything - called apple support, called Verizon tech support, exchanged the phone and sim card, and tried all the network reset options.  It will stays in 3G..sp

  • Problem after copying to external HD

    I just bought an external HD to backup my music collection in iTunes. After I copied the iTunes folder to the external HD, my iTunes library changed. When I tried to open iTunes, I was asked to pick a library. Apparently I picked the wrong one, as my

  • MacBook Air i5 vs i7

    Hey guys, i'm going to buy the macbook air with 8gb ram and 256gb ssd. I was wondering if i should go to i5 or i7. I won't be doing really intensive work, no photoshop or editing movies or photos or whatnot. Hope you can give me an answer! Thanks! (p