For loop - find index

Hey all
How do I get the "i" in the "onRelease" function to match with the "i" in another array? When I click the "ch_mc" button, the aVar array all returns "0".
nor = new Array();
nor[0] = a_mc;
nor[1] = b_mc;
nor[2] = c_mc;
aVar = new Array();
aVar[0] = 0;
aVar[1] = 0;
aVar[2] = 0;
for (i=0; i<nor.length; i++)
    nor[i].onRelease = function() {
        aVar[i] = 1
        trace(aVar[i]);
ch_mc.onRelease = function() {
    for (j=0; j<nor.length; j++)
    trace(aVar[j]);
Thanks

use: 
nor = new Array();
nor[0] = a_mc;
nor[1] = b_mc;
nor[2] = c_mc;
aVar = new Array();
aVar[0] = 0;
aVar[1] = 0;
aVar[2] = 0;
for (i=0; i<nor.length; i++){
    nor[i].ivar=i;
    nor[i].onRelease = function() {
        aVar[this.ivar] = 1
        trace(aVar[this.ivar]);
ch_mc.onRelease = function() {
    for (j=0; j<nor.length; j++)
    trace(aVar[j]);
Thanks

Similar Messages

  • For loop array index not from 0

    HI!
    I have an array that is wired into a For Loop. Inside the For Loop there is already a single Array content available as there is this autoindexing feature (?). I do want to change the Array from a certain position different from 0 onwards to the end e.g. change positions 4, 5 and 6 in a for loop executing 3 times. But the for loop and the autoindexing feature start at 0. Can I change this in an elegant way. At the moment I'm running thru the hole array and begin changing at a certain position.

    Yes, disable autoindexing on the tunnel and use "index array" inside the loop. Use [n]+4 as index and wire a "3" to the loop count in your particular example.
    If you want to keep the entire array and just replace a few elements with updated values, the array needs to be fed in via a shift register. Write the new elements at the desired position using "replace array subset" (see attached very simple example).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ReplaceSomeArrayElements.gif ‏3 KB

  • Using a For Loop Index for Array Element Number?

    Hi.  Thanks in advance for the help.  I can't seem to find what I want to do here using the search function... probably because I don't know how to frame the question appropriately.  Ignore the title to this post cause it's probably wrong vocabulary for what I want to do.
    Here's the situation:
    I have a 2D array where the first column is the X data and each subsequent column is Y data (call it Y1...Yn).  The n-value varies from run to run (some runs have 4 columns of data, some have 20), but that is easily gathered when reading the data file.  I need to perform a number of operations on each set of data, the least of which is smoothing the data and graphing it, so I'm limiting my discussion to these 2 operations.
    What I want is a for loop structure where the indexing of the loop tracks the Y1...Yn columns, grabs each column for the iteration, performs the relevant analysis, and spits out the result, but in a stackable manner.  Thus the title; I want to use the for loop's index to mark the array element for building a new array.
    See the image attached.  A 2D array of 9 columns (X, Y1...Y8) is analyzed such that each data set, (X, Y1), (X, Y2)...(X, Y8) is bundled, graphed, run through a B-spline Fit, of which is also graphed.  I need to replace this with something that looks like the for loop structure shown.  
    I just don't know how to get those two data bundles [(X, Yi) and it's smoothed pair] out of the for loop in a stacked set from every iteration of the for loop.
    Again the title, I think I want to build a new array where i use the index of the for loop to control the entries of the new array.  But I can't see how to do that.
    Any help would be appreciated.
    Attachments:
    NeedForLoopForThis.PNG ‏30 KB

    Hello H.R. Dunham, and welcome to the forum!
    It seems that you may be looking for Auto-Indexing, a basic feature of loops in LabVIEW.  You'll need to transpose your array before wiring it into the for loop, as elements are auto-indexed by row before column, but at that point you should be able to operate on each column and output an array of n cluster elements corresponding to your input columns.  Auto-indexing tunnels look like brackets to indicate each element will be indexed automatically- this should be the default when wiring an array into a for loop or when wiring anything out of a for loop.
    As for how to build your pairs, I suggest removing the X column and creating a "starter" cluster containing your X data and placeholder Y data before entering your "Y" processing loop.  Use the bundle by name function in the for loop to insert your processed column data into the cluster and auto-index the cluster output. Flow would be something like this:
    1) Gather data
    2) Split X and Y using standard array operations
    3) Create "template" cluster with shared X data
    4) Pass template cluster and Y-column array into an auto-indexed for loop.
    5) Insert processed Y data into cluster inside loop.
    6) Auto-index cluster data out of loop.
    This tutorial is probably also a good place to get started:
    Getting Started with NI LabVIEW Module 3: Loops
    http://www.ni.com/white-paper/7528/en/
    Hope that helps!
    Regards,
    Tom L.

  • How do I find the range of a bunch of #'s using for loops?

    I have a program that gets 13 numbers from the user and I nned to find the range of them. How do I do this with for loops?

    This is what I have so far
    if (one > two && one > three && one > four && one > five && one > six && one > seven && one > eight && one > nine && one > ten && one > eleven && one > twelve && one > thirteen)
                   big = one;
              else if (two > one && two > three && two > four && two > five && two > six && two > seven && two > eight && two > nine && two > ten && two > eleven && two > twelve && two > thirteen)
                   big = two;
              else if (three > two && three > one && three > four && three > five && three > six && three > seven && three > eight && three > nine && three > ten && three > eleven && three > twelve && three > thirteen)
                   big = three;
              else if (four > two && four > three && four > one && four > five && four > six && four > seven && four > eight && four > nine && four > ten && four > eleven && four > twelve && four > thirteen)
                   big = four;
              else if (five > two && five > three && five > four && five > one && five > six && five > seven && five > eight && five > nine && five > ten && five > eleven && five > twelve && five > thirteen)
                   big = five;
              else if (six > two && six > three && six > four && six > five && six > one && six > seven && six > eight && six > nine && six > ten && six > eleven && six > twelve && six > thirteen)
                   big = six;
              else if (seven > two && seven > three && seven > four && seven > five && seven > six && seven > one && seven > eight && seven > nine && seven > ten && seven > eleven && seven > twelve && seven > thirteen)
                   big = seven;
              else if (eight > two && eight > three && eight > four && eight > five && eight > six && eight > seven && eight > one && eight > nine && eight > ten && eight > eleven && eight > twelve && eight > thirteen)
                   big = eight;
              else if (nine > two && nine > three && nine > four && nine > five && nine > six && nine > seven && nine > eight && nine > one && nine > ten && nine > eleven && nine > twelve && nine > thirteen)
                   big = nine;
              else if (ten > two && ten > three && ten > four && ten > five && ten > six && ten > seven && ten > eight && ten > nine && ten > one && ten > eleven && ten > twelve && ten > thirteen)
                   big = ten;
              else if (eleven > two && eleven > three && eleven > four && eleven > five && eleven > six && eleven > seven && eleven > eight && eleven > nine && eleven > ten && eleven > one && eleven > twelve && eleven > thirteen)
                   big = eleven;
              else if (twelve > two && twelve > three && twelve > four && twelve > five && twelve > six && twelve > seven && twelve > eight && twelve > nine && twelve > ten && twelve > eleven && twelve > one && twelve > thirteen)
                   big = twelve;
              else if (thirteen > two && thirteen > three && thirteen > four && thirteen > five && thirteen > six && thirteen > seven && thirteen > eight && thirteen > nine && thirteen > ten && thirteen > eleven && thirteen > twelve && thirteen > one)
                   big = thirteen;
              if (one < two && one < three && one < four && one < five && one < six && one < seven && one < eight && one < nine && one < ten && one < eleven && one < twelve && one < thirteen)
                   little = one;
              else if (two < one && two < three && two < four && two < five && two < six && two < seven && two < eight && two < nine && two < ten && two < eleven && two < twelve && two < thirteen)
                   little = two;
              else if (three < two && three < one && three < four && three < five && three < six && three < seven && three < eight && three < nine && three < ten && three < eleven && three < twelve && three < thirteen)
                   little = three;
              else if (four < two && four < three && four < one && four < five && four < six && four < seven && four < eight && four < nine && four < ten && four < eleven && four < twelve && four < thirteen)
                   little = four;
              else if (five < two && five < three && five < four && five < one && five < six && five < seven && five < eight && five < nine && five < ten && five < eleven && five < twelve && five < thirteen)
                   little = five;
              else if (six < two && six < three && six < four && six < five && six < one && six < seven && six < eight && six < nine && six < ten && six < eleven && six < twelve && six < thirteen)
                   little = six;
              else if (seven < two && seven < three && seven < four && seven < five && seven < six && seven < one && seven < eight && seven < nine && seven < ten && seven < eleven && seven < twelve && seven < thirteen)
                   little = seven;
              else if (eight < two && eight < three && eight < four && eight < five && eight < six && eight < seven && eight < one && eight < nine && eight < ten && eight < eleven && eight < twelve && eight < thirteen)
                   little = eight;
              else if (nine < two && nine < three && nine < four && nine < five && nine < six && nine < seven && nine < eight && nine < one && nine < ten && nine < eleven && nine < twelve && nine < thirteen)
                   little = nine;
              else if (ten < two && ten < three && ten < four && ten < five && ten < six && ten < seven && ten < eight && ten < nine && ten < one && ten < eleven && ten < twelve && ten < thirteen)
                   little = ten;
              else if (eleven < two && eleven < three && eleven < four && eleven < five && eleven < six && eleven < seven && eleven < eight && eleven < nine && eleven < ten && eleven < one && eleven < twelve && eleven < thirteen)
                   little = eleven;
              else if (twelve < two && twelve < three && twelve < four && twelve < five && twelve < six && twelve < seven && twelve < eight && twelve < nine && twelve < ten && twelve < eleven && twelve < one && twelve < thirteen)
                   little = twelve;
              else if (thirteen < two && thirteen < three && thirteen < four && thirteen < five && thirteen < six && thirteen < seven && thirteen < eight && thirteen < nine && thirteen < ten && thirteen < eleven && thirteen < twelve && thirteen < one)
                   little = thirteen;
    I'm trying to fix this so it's not so confusing with for loops

  • For loop indexing?

    Is it possible to change indexing step in labView "For Loop" structure? By
    default this value is 1, and I need to make a step value different from "1"
    like in C example:
    for (index=0; index < 100; index++) {}; // step=1
    for (index=0; index < 100; index=index+3) {}; // step=3
    Sergey Yakovlev, Berlin,
    [email protected]

    Hallo, Sergey,
    Du (yakovlev) meintest am 21.09.01 zum Thema for loop indexing?:
    > Is it possible to change indexing step in labView "For Loop"
    > structure? By default this value is 1, and I need to make a step
    > value different from "1" like in C example:
    > for (index=0; index < 100; index++) {}; // step=1
    > for (index=0; index < 100; index=index+3) {}; // step=3
    What about
    j:=i*3
    and i is incremented by 1
    Greetings!
    Helmut
    Please excuse my gerlish!

  • Why are date and time strings lost when indexing an array in a for loop

    Hi, 
    I have an application where i'm reformatting data from a spreadsheet for graphical display on a LabVIEW dashboard.
    the original spreadsheet has date and time values in separate columns, and i'm merging them and converting to a timestamp value.  But something's not working.  Does anyone know why the string value is lost when the array indexes into this for loop?
    Attachments:
    failed array index.png ‏142 KB

    Can you attach your VI with some typical values? (e.g. create in indicator on the 2D array, run your VI, then turn the indicator (now containing data) into a diagram constant). Place the FOR loop related code and that diagram constant into a new VI and attach it here.
    How many times does the FOR loop run? Could it be that the last element of each 1D array is an empty string? (unless you put a wait inside the FOR loop, you'll never see the other elements in the probe)
    LabVIEW Champion . Do more with less code and in less time .

  • Indexing data on a for loop to overlay data on a xy graph

    I am using express VI's to measure both voltage and current data in a For Loop. I want to plot a current vs voltage graph but have each iteration of the loop overlay the others as if it were its own independent data set. I have been unable to bundle the data and convert it into a xy graph because of the number of elements, 3 for the bundle and 2 for the graph. I need a method to index the dynamic data wires so that I can overlay them.

    Hello,
    After reading the thread, it sounds like you're looking for a chart-like graph - I have attached an example with illustrates this.  Keep in mind that "graphs" in LabVIEW generally plot arrays of data (in the case of an XY graph, you pass a cluster which contains an X and Y array).  The example behaves like a chart by building an array one data point at a time (in this case both an X and Y array of course) on each iteration of a loop, and displaying the data at each loop iteration - this gives the look and feel of a chart which accumulates data.  It is attached in version 7.1 - hopefully you have that version or later to open it.  I have also attached a program which shows how to plot multiple data sets on an XY graph, in all 3 current formats accepted by the XY graph - it's attached in version 8.0 because the ability to plot complex data to an XY graph was added to version 8.0, and it illustrates this as well.
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    XY Chart-like Example.vi ‏24 KB
    XYGraphWithArbitrarilyManyPlots.vi ‏32 KB

  • Index out of Bounds Exception in for loop.

    Occasionaly with the code below, i get an index out of bounds error, index 1, size 1, however the for loop should ensure that it never calls the getActorLocation method if the index is the same size as the arrayList size.
    Im having one of those days, and i just cant see what error i have made.
    Perhaps i need coffee? lol
    Cheers
    James
    private void checkMemoryIntegrity(){
            Actor actor = actorList.get(actorIndex);
            ArrayList<Integer> inRangeList = getActorsInMemoryRange(actor, actor.getRange());
            inRangeList.trimToSize();
            for (int i = 0; i < inRangeList.size();i++){
                if (inRangeList.size() != 0){
                    actor = brainState.getActorLocation(i); //<<<<<<<<< problem line
                    if (!actorList.contains(actor)){
                        brainState.actorLocations.remove(i);
    public ArrayList <Integer> getActorsInMemoryRange(Actor actor, int range){
            int i = 0;
            int x = actor.getX();
            int y = actor.getY();
            ArrayList <Integer> inRangeList = new ArrayList <Integer> ();
            Actor compActor;
            while (i< brainState.actorLocations.size())
                compActor = brainState.getActorLocation(i);
                int xDist = x - compActor.getX();
                if ( (xDist >= (-1) * range) && (xDist <= range) ){
                    int yDist = y - compActor.getY();
                    if ( (yDist >= (-1) * range) && (yDist <= range) ){
                        inRangeList.add(i);
                i++;
            return inRangeList;
        }

    I was thinking it might be easier to do it this way:
    Iterator<Actor> i = actorLocations.iterator();
    while(i.hasNext())
        if (!actorList.contains(i.next())) {
            i.remove();
    }It sounds like you have an equals() method which compares the x and y locations of the actor. If not then you will have to enclose the remove in an if block which compares the actor location. Does that make sense?
    Edit: contains uses the equals method.
    Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that
    (o==null ? e==null : o.equals(e)).Edited by: Edward_Kimber on May 23, 2008 11:43 AM

  • How to index a array to give it to for loop for one value at a time sequence to be ensured

    I need to give one number from a array at a time to a for loop. means the for loop have to execute one number at a time  from a array of numbers. How to do it

    Ranjeet,
    Ranjeet_Singh wrote:
    But question is same only. is in it ?
    With all due respect, NO.
    Please make sure you know what you are talking about before blatantly countering someone else's comment. Can you prove that your vi and TiTou's snippet will do the same thing?
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Conditiona​lly Indexed For Loop Terminal

    Dear LabVIEW community!
    Most of you, I’m sure, know and use in LabVIEW 2012 such useful and helpful feature as conditional terminal in For Loop (see it on the picture below).
    But if one saves such code in previous versions of LabVIEW, then we see, that code has different look (VI Snippet was made in LV 2012, so don’t be confused – it is really code in LV 2011).
    The same algorithm is made by using case structure and shift register. But the problem is that this shift register is uninitialized (1) (we have some constant (2) on the block diagram after saving file in previous version, but it is wrong constant for our case), and you know, that it can cause unexpected behavior of the program. So, if you have to convert such a code to previous versions of LabVIEW, don’t forget to check it, and initialize that shift registers.
    Solved!
    Go to Solution.

    Wow! I had no idea this little "conditional terminal" existed. I've been doing Example B all this time, and it sometimes really causes my BDs to elongate. I don't know about you, but my programming always to contain the best examples of "The drawing will fill the space available - and then some." Now, I'll get to stick in one or two more bits before I hit the right-hand wall. Thanks.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • For Loop and Void Method Questions

    Question 1: How would I write a for loop that repeats the according to the number entered, to prompt the user to enter a number (double) between 1 and 100. If the number is outside this range it is not accepted.
    Question: 2 Also how would I write a for loop to do sum and find the average of the array numbers in a seperate void method( does not return anything to the main method)?
    Question: 3 (first code snippet) With my for loop that is used to process each number in the array and square it and cube it and display the results to 2 decimal places. How do I make it so say I want the array to allow me to enter 2 numbers (so I enter 2 numbers) then it asks me to enter a number between 1 -100 (which will prompt 2 times) that it shows me the results for the entered numbers between 1-100 after one another instead of number then result number then result like I how it now.
    for (int index = 0; index < howNum; index++) // process each number in the array
              enterYourNumbers = JOptionPane.showInputDialog   
                            ("Enter a number between 1 and 100");                       
              numArray = new double[howNum]; 
            try
                numArray[index] = Double.parseDouble(enterYourNumbers);
            catch (NumberFormatException e)
                    enterYourNumbers = JOptionPane.showInputDialog
                              ("Enter a number between 1 and 100");                          
                DecimalFormat fmt = new DecimalFormat ("###,###.00");
                JOptionPane.showMessageDialog(null, enterYourNumbers + " "  + "squared is "  + fmt.format(calcSquare(numArray[index]))
                                              + "\n" + enterYourNumbers + " " +  "cubed is " + fmt.format(calcCube(numArray[index])));                                                                           
                wantToContinue = JOptionPane.showInputDialog ("Do you want to continue(y/n)? ");
      while (wantToContinue.equalsIgnoreCase("y"));
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class Array
        public static void main(String[] args)
            int howNum = 0;
            int whichNum = 0;     
            double[] numArray;
            boolean invalidInput = true;
            String howManyNumbers, enterYourNumbers, wantToContinue;
      do // repeat program while "y"
          do // repeat if invalid input
            howManyNumbers = JOptionPane.showInputDialog
                        ("How many numbers do you want to enter");                     
            try
                 howNum = Integer.parseInt(howManyNumbers);
                 invalidInput =  false;
            catch (NumberFormatException e )
                howManyNumbers = JOptionPane.showInputDialog
                            ("How many numbers do you want to enter");
          while (invalidInput);
          for (int index = 0; index < howNum; index++) // process each number in the array
              enterYourNumbers = JOptionPane.showInputDialog   
                            ("Enter a number between 1 and 100");                       
              numArray = new double[howNum]; 
            try
                numArray[index] = Double.parseDouble(enterYourNumbers);
            catch (NumberFormatException e)
                    enterYourNumbers = JOptionPane.showInputDialog
                              ("Enter a number between 1 and 100");                          
                DecimalFormat fmt = new DecimalFormat ("###,###.00");
                JOptionPane.showMessageDialog(null, enterYourNumbers + " "  + "squared is "  + fmt.format(calcSquare(numArray[index]))
                                              + "\n" + enterYourNumbers + " " +  "cubed is " + fmt.format(calcCube(numArray[index])));                                                                           
                wantToContinue = JOptionPane.showInputDialog ("Do you want to continue(y/n)? ");
      while (wantToContinue.equalsIgnoreCase("y"));
        public static double calcSquare(double yourNumberSquared)
            return yourNumberSquared * yourNumberSquared;       
        public static double calcCube(double yourNumberCubed)
           return yourNumberCubed * yourNumberCubed * yourNumberCubed;              
        public static void calcAverage(double yourNumberAverage)
    }

    DeafBox wrote:
    Question 1: How would I write a for loop that repeats the according to the number entered, to prompt the user to enter a number (double) between 1 and 100. If the number is outside this range it is not accepted. Use a while loop instead.
    Question: 2 Also how would I write a for loop to do sum and find the average of the array numbers in a seperate void method( does not return anything to the main method)? Why would you want to use 2 methods. Use the loop to sum the numbers. Then after the loop a single line of code calculates the average.
    Question: 3 (first code snippet) With my for loop that is used to process each number in the array and square it and cube it and display the results to 2 decimal places. How do I make it so say I want the array to allow me to enter 2 numbers (so I enter 2 numbers) then it asks me to enter a number between 1 -100 (which will prompt 2 times) that it shows me the results for the entered numbers between 1-100 after one another instead of number then result number then result like I how it now. If I understand you correctly, use 2 loops. One gathers user inputs and stores them in an array/List. The second loop iterates over the array/List and does calculations.

  • SOLUTION - Re-Index Loops when "Index Now" button is broken

    This message is for anyone having trouble with Soundtrack's loop indexing in the following way:
    PROBLEM:
    ... You want to re-index some loops, or
    ... You want to de-index some loops, or
    ... Some loops are showing up red
    AND...
    ... You cannot re-index from the "Setup..." button in the Search palette (the minus button and/or "Index Now" buttons are grayed out for some unknown reason)
    *HERE IS THE POSSIBLE SOLUTION:*
    ... Delete all files from the following folders:
    Library/Preferences/Soundtrack/
    Library/Audio/Apple Loops Index/
    ... Now restart Soundtrack, and click "Setup...". All the indexed directories should be gone.
    ... You'll have to re-add and re-index your whole library. This may also affect GarageBand and/or Logic, and require re-indexing in them as well.
    *If you're still having trouble...* there may be some more index files floating around your system. Open Spotlight and set "System Files are Included" and "File Name" in the search options and search for "search index". This should show you where any remaining Apple Loop search index files are located, so you can delete them. They will be named stuff like "Search Index E44B5969-5E4A-4E27-A3C2-E5861C5D1FB8.txt".
    Hope this helps anyone else out there. It worked for me with Soundtrack 1.1 when my loops were all messed up.

    Well, to add metadata and transients to sound clips you need to edit them in Apple Loop Utility which is included with Final Cut Studio.
    To add custom loops to your permanent library you need to make a new folder like "My Loops" and put it somewhere permanent like in Library/Audio/Apple Loops and then index it with Soundtrack/GarageBand/Logic. Soundtrack uses the "Setup..." list and GarageBand you can just drag and drop into the loop browser. Not sure about Logic but it should be something similar.
    If you wanted to edit the index files manually from the Finder, they are in some weird format and I don't think it's possible.

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • How can I have each pass through a for loop communicate with a new indicator?

    Hello,
    I am using 16 color boxes to indicate how 16 channels are behaving.  If a color box is blue, its respective channel is running correctly, red means it has failed etc.  I am continuously checking each channel using a loop, and I wanted to update the channel colors every loop.  I have made an array of 16 numbers corresponding to the color I wish to have (which are blue = running, red = failed, green = completed, black = not in use).  However, I cannot find a way to pull these 16 numbers out of the array and to the color boxes short of 16 index arrays connected to the color boxes. 
    I understand how to convert each individual number to a color, I just don't know how to use a 16 times for loop to communicate with a different color box each pass through.  Is there any way to do this or should I just go for brute force?
    Thank you.
    Solved!
    Go to Solution.

    Sorry I keep making new posts.  Attached is an example i wrote up.  There are three cases in the disabled structure, each has a different implementation of what i belive your specs are.
    Tim Elsey
    LabVIEW 2010, 2012
    Certified LabVIEW Architect
    Attachments:
    update color box.vi ‏24 KB

  • Is it possible to use a "for loop" structure to represent DAQ of 16 channels?

    Hi,
    I tried to search but I failed to find a similar problem so I am posting this problem here.
    I have a temperature DAQ board which has 16 channels, and I am using all 16 channels to record and monitor temperature data.
    When I writed blocks for all 16 channels, a mess was created (as you can see in my attached program). I have noticed that all the VIs for the 16 channels have similar structure, so I was thinking whether we can represent all 16 channels with a "for loop" strucutre with a pointer i scanning from i=1 to 16 as we usually do in Matlab or Fortran.
    For instance, we may try to simplify the code like:
    for i=1:1:16
         acquire data from channel i
         show data from channel i in X-Y graph
         write data from channel i to excel in every 10 seconds
    end  
    I could not do it myself because I cannot find a "pointer" to represent each channel.
    Does anyone know how to do this in LabVIEW? Thank you.
    It is said that it is best if we can put all of our code within the screen of a monitor we use by using subVIs to divide the code into many subroutines. But I found it quite difficult to do so as I have too many controls as inputs and indicators as outputs. Also, I use property node to read and write frequently, which make things harder....
    Attached code does not work as it requires the 9213 hardware, and for simplicity I deleted irrelavent modules. But if you need I can upload one that may work by modifying the read VI.
    Thank you.
    Attachments:
    ask for help.vi ‏132 KB

    Yup, instead of all these 1D arrays, use a single 2D array. Your code could be reduce to <10% of the current size. I am sure it would fit easily on a single screen.
    Also try to do some tutorial or take some courses. I realy don't think you are ready to tackle a system of this magnitude at this time.
    Your code is just peppered with very poor choices. Some things you apparently haven't figured out:
    index array is resizable. There is no need to create dozens of parallel instances, all wired to the same array and all with a unique index diagram constant. If you want all elements in order, the indices don't need to be wired at all.
    Replace all your value property nodes with local variables. Much more efficient. Then redesign the code so you don't even need most of the local variables.
    You can use built array to append elements to an existing array. Using "insert into array" is much more complicated an error prone.
    It is not a good idea to have deeply stacked while loops with the innermost loop having long delays and indeterminate stop conditions. That just gums up the gears.
    Learn about proper code architectures, state machines, etc.
    Get rid of that gigantic, all encompassing stacked sequence. I am sure you can find a better way to reset three booleans when the code is about to stop. In fact it is typically more reasonable to set things to a defined state when the program starts to avoid problems due to accidental value changes at edit time.
    Don't use hidden control/indicators as data storage and interloop communication via local variables. There are better ways.
    You can wire the reminder or Q&R directly to a case structure. No need for e.g. "=0".
    Don't use ambiguous labels, e.g.a boolean labeled "Dampers on or off". Nobody will be able to later figure out if TRUE corresponds to ON or OFF. Could it be that TRUE mean it is either ON or OFF and FALSE that it is in some imternediate position?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • Can I connect my my macbook pro to a Vizio 32" LED HDTV?

    I have a 15-inch Mid-2009 Macbook Pro that I currently have connected to an external monitor, using a mini displayport to DVI. I would like to now connect my computer to Vizio E320-AO 32" Class LED HDTV (720p;60Hz). I will be purchasing a dvi-hdmi ad

  • Ability to Filter within an idividual perspective in a Tabular Model (cube)?

    I have a rather large Tabular model that I would like to use across 10 different reports as the requirements are identical, save for 1 aspect - the report goes out to 10 different companies. I need to be able to limit each result set by the individua

  • How to convert data type while using @variable function

    Hi Gurus, I have a query. i have created a Derived Table and the statement is given below. select 1 as SENSITIVITY_LEVEL,1 as SUBSENSITIVITY,@variable('US_T') as NITEMS, ........... here  in @variable('US_T') "US_T" is hard coded value. I want to cha

  • IPhone screen frozen with the "restore" logo on it

    I can not get my computer to reconize the iPhone anymore. My phone is stuck on the "restore" screen and iTunes won't reconize it. I've tried reinstalling iTunes, rebooting the computer, holding down the power and home keys for 10 seconds .. nothing.

  • Oracle Jinitiator latest version

    Hello! which is the latest version of Oracle Jinitiator available for oracle forms and which parameters to be reconfigure for usage of newer version (if available) Thanks in Advance