Making array while looping another array

hi all,
i have an array of int values.
i need to make a list of another values while looping around the int values.
but the values that are added to the list are objects
can any one help me with the sample code in getting the list
any ideas?
regards and thanks in advance

Double-posted
http://forum.java.sun.com/thread.jspa?threadID=648140

Similar Messages

  • Making a while loop stop

    I'm trying to write to a file by using a while loop. I read from the keyboard and then enter the while loop. I print to the file and then I read from the keyboard again. My problem is when I want to exit the loop by entering nothing I can't. The loop becomes infinite. Please help!!! Here is my code!!
    inputline = keyboard.readLine();//read the keyboard
    while ( inputline != null ){
    DiskOut.println( inputline );
    DiskOut.flush();
    inputline = keyboard.readLine();//read the keyboard again
    }//end while

    At a guess, it's not returning null when you hit return, but rather the return character. Try something like
    if (inputline == "" || inputline =="\n" || inputline == "\r" || inputline == null) {break;}If that works, you can take out bits to see what it is returning.

  • How can I make a while loop wait for input boolean?

    Hi.
    I'm trying to control a robotic arm with labview for my undergrad dissertation, and I have a decent polar coordinate control panel made, but there is one problem; it checks for changes in the coordinates every five seconds, while I want it to only check on the touch of a button (ie, go!, I've changed your coordinates!). The changes are calculated with a while loop comparing the last value of theta, x and z in a while loop with the current one. I can't find a way of putting that into a case structure. If there is a way of making the while loop progress at the push of a button, I think it would work. The VI's attached below.
    Thanks in advance for any help.
    Cathal Scanlon
    ps, sorry about the mess, I'm going to reorganise the while loop into 2 if I can get the control button working.
    Message Edited by CatScan on 02-08-2007 02:45 PM
    Attachments:
    Polar coord assignment1.vi ‏142 KB

    Have you tried using an event structure? To use one, right click on the structure to add an event. Set the event as whatever button you wish to monitor and set the event to "Value Change". If you put this inside a while loop any time the button is pressed, the event structure will run the contents inside the loop. There are a number of options to have the event structure activate.
    *** Warning! I'm probably the last guy you want answering your labVIEW questions, but I figured I might be able to help.

  • Iteration Speed issue when Indexing 3D array wried to a while-loop

    Brief Description of my Program:
    I am working on the real-time signal generation by using LabView and DAQmx (PCI-6110 card). My vi reads the big data file (typically 8MB txt file containing about 400,000 samples (complex double precision). Then, the signal is pre-processed and I end up with a huge 3D array to feed while-loop (typically 3D array dimension is N x 7 x M where N & M >> 7). Inside the loop, that 3D array is indexed and processed before the results are written to the DAQmx outputs. I have a speed issue when indexing the large 3D array (i.e, 3D array having a large sub-array size). My while-loop could not run fast enough to top-up the DAQmx AO buffer (at the output rate of 96kHz). It could run faster only if I use smaller 3D array (i.e, smaller-sized sub-arrays). I do not quite understand why the size of 3D sub-array affects the rate of looping although I am indexing same sub-array size at each iteration. I really appreciate your comments, advices and helps.
    I include my 3D array format as a picture below.
    Question on LabView:
    How does indexing an 3D array which wires to the while-loop affect the speed of the loop iteration? I found that large dimension of sub-arrays in the 3D array slows down the iteration speed by comparing to indexing the same size of sub-array from smaller-sized sub-arrays of the 3D array to perform signal processing inside the while-loop. Why? Is there any other way of designing LabView Program to improve speed of iteration?
    attachment:

    Thank you all for your prompt replies and your interests. I am sorry about my attachment. But, I have now attached a jpg format image file as you suggested.
    I had read the few papers on large data handling such as "LabVIEW Performance and Memory Management". Thus, I had already tried to avoid making unnecessary copies of data and growing arrays in my while-loop. I am not an expert on LabView, so I am not sure if the issues I have are just LabView fundamental limitations or there are any other ways to improve the iteration speed without reducing the input file size and DAQ output rate.
    As you request, I also attach my top-level vi showing essential sections such as while-loop and its indexing. The attached file is as an image jpg format because the actual vi including Sub-VIs are as big as 3MB in total. I hope my attachment would be useful for anyone who would like to reply my question. If anyone would like to see my whole vi & llb files, I would be interesting to send it to you by an e-mail privately and thus please provide your e-mail address.
    The dimension of my 3D array is N x 7 x M (Page x Row x Column), where N represents number of pages in 3D array, and M represents the size of 1D array.  The file I am currently using forms 3D array of N = 28, & M = 10,731.  Refering to the top-level vi picture I attached, my while-loop indexes each page per iteration and wrap-around.  The sub-VI called "channel" inside the while-loop will further index its input (2D array) into seven of 1D arrays for other signal processsing.  The output from that "channel" sub-VI is the superposition of those seven arrays.  I hope my explaination is clear. 
    Attachement: 3Darray.jpg and MyVi.jpg
    Kind Regards,
    Shein
    Attachments:
    3Darray.jpg ‏30 KB
    MyVI.jpg ‏87 KB

  • Using while loops instead of for loops in arrays?

    I am new to java and doing a java tutorial on using arrays and for loops. What im trying to find out is how it is possible to use a while loop instead.
    I would be very grateful if anyone can suggest a way of changing my code to use a while loop.
    The code I have written is:
    public class DetermineGrade
    public static void main(String[]args)
    final char[] mark = {'A','B' ,'C' ,'D' ,'F' };
    char [] grade = new char[5];
    int [] Score ={95,35,65,75};
    for (int i=0; i<4; i++)
    if (Score >= 90)
    grade= mark[0] ;
    else if (Score >=80)
    grade = mark[1] ;
    else if (Score >=70)
    grade = mark[2] ;
    else if (Score >=60)
    grade = mark[3];
    else grade = mark[4];
    for (int i=0; i<4; i++)
    System.out.println("grade = " + Score + ", " + grade);
    Thankyou LB

    Im trying to underdstand the differences in the
    different loops. I can grasp the for loop but I dont
    see how a while loop works, or how it id different
    from the other?
    for (j = INIT; j < MAX; j++) {
        // do stuff
    }is the same as
    j = INIT;
    while (j < MAX) {
        // do stuff
        j++;
    }Lee

  • How do we save three 1D arrays in while loop as an excel file? I used build array, waveform. I could not make it work.

    I have three separate 1 dimensional arrays in a while loop. I need to combine these arrays and save as a excel file outside the loop.
    My second question is that is there any emergency STOP button in Labview so that when I press that button, it cuts all the power going to the system. Thanks...

    Just a comment on the Stop button.
    It's not really a good idea to rely solely on a software emergency shutdown. Especially if the shutdown is to prevent some type of hazardous condition to the people running the test. The problem is that if your application or PC in general is having some type of problem, it may not be able to shut everything down as needed.
    You should always have a mechanical �Big Red Stop Button� that you can hit to cut power to everything. In addition to the button, I usually do have LabVIEW monitor things and if conditions are not looking good, have it automatically shut things down. This has always worked good, and I can�t remember any time I�ve actually had to use the big button, but it�s nice to know it�s there.
    VERY IMPORT
    ANT:
    Using the �Abort� button on the LabVIEW toolbar is NOT the thing to do. This stops your application where ever it is in its execution and does not allow it to finish or execute any shutdown code you might have put in. A �Kill� button on the front panel works well. I�ve put a single Boolean terminal in its own little While loop to monitor it. It usually writes to a digital line that�s holding a relay on that will cut the power.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • How to avoid Build Array function inside a For (while) Loop?

    Hi there,
    I have a simple question about how to avoid using Build Array function inside the loop. Now I want to remove the Build Array funtion inside the loop to improve the performance (To get better memory management). Any idea how to do that?
    Thanks a lot!
    Warmest regards,
    Chong

    It's been my experience that using the auto-indexing to build an array
    on a For loop is just as good as initializing and replacing elements.
    The For loop knows before it runs how many iterations it has to run and
    can allocate the array ahead of time.
    You're better off initializing and replacing when using a While loop
    because it does not know how many iterations it will run and can't
    pre-allocate the array ahead of time.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Add to new values to an existing 1D array in a while loop

    Hello,
    I have a while loop that collects data from a DAQ Assistant and stores it into a 1D array. The number of loops is set by the user. I am trying to average the data from each iteration of the loop. So far I am only able to get the array to overwrite the previous array values with the new ones.
    if Number of loops = 3
    First Iteration                      Second Iteration                         Third Iteration                           New 1D Array        [Divide by Loop #
    4.97                                      4.99                                               4.98                                            14.94                       for the average]
    4.97                                      4.99                                               4.98                                            14.94
    4.96                                      4.98                                               4.97                                            14.91
    4.98                                      5.00                                               4.99                                            14.97
    4.97                                      4.99                                               4.98                                            14.94
    I would like to make this as general as possible as the loop number will vary depending on the user input. 
    Solved!
    Go to Solution.

    sgtpppr685 wrote:
    I like the creative solution you have provided however, I am trying to keep the average at each element so that I can graph the average at each point. Therefore, I need the average to be a 1D array of the same initial length, not a scalar. 
    I am trying to avoid using shift registers.
    1. Do you mean you want the average after each iteration as well?  This can be done pretty easily by moving the division inside my loop.  Perhaps I am misunderstanding you though.
    2. Why avoid shift registers?  They are amazing and effective.  They are an essential LabVIEW tool imo   Plus they work wonderfully for your current problem.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If someone helped you out, please select their post as the solution and/or give them Kudos!

  • While Loop to Monitor a 1D 8Bit boolean Array for changes

    Hi;
    I need help in monitoring a 1D 8-bit boolean array for a value change. I think I need to use a while loop with shift registers???
    Any suggestions?
    Thank you,
    4BoysDaD

    Where are you going to put it in your code. It will depend on what you are already doing. Here is an example to show you how to do it with out shift registers.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Example.vi ‏8 KB
    Check of 1D Boolean Array has Changed.vi ‏8 KB

  • What is the maximum size of indexed array that can be created during execution of while loop?

    Hello,
    I am using a ring acquisition to take in images. If i write them as files in the loop, it slows down the acquisition unacceptably. Therefore i am converting image to array and storing the array until the acquisition is complete and then reading the array and converting back to image to save. The program sometimes runs out of memory (after a couple of minutes). Can anyone think of a way where i can store the array/images within the execution (without losing image information), without slowing it down and to avoid this memory problem?
    I have included the VI.
    Thanks in advance for any help or advice.
    kindest regards,
    FraserD
    Attachments:
    LL_Ring_in_IMAQ_8_bit_array_then_write_as_png.vi ‏94 KB

    When you build the array of pictures you do it using auto-indexing out of a while loop. That means that memory is aquired for a copy of the previous picture array and the array is rebuilt on every iteration, this is slow and requires a lot of extra memory.
    If you want to speed things up try initializing a shift register with a 3D array of a size that will be able to hold a certain number of pictures, then replace the "pages" as new pictures are aquired, replace operations do not require copying of the previous array and will thus be much much faster. The difference is exeptional when dealing with large arrays/amounts of data.
    Now, the shift register buffer could be built into a functional global, and you can add a push/pop logic to it so that you can have a p
    arrallell loop that works on writing the elements to disk. You could use a que for this, but I think even though you specify a size limit to the que it still aquires memory as new elements are added (correct me if I'm wrong people...:-)), so a functional global acting as a circular buffer og fixed size frame for a que should be better.
    MTO

  • How to print an array out a while loop?

    Hi all,
    I'm very new with Labview (6h of Practice) and I meet a problem.
    I create a while loop in which a read the first characters of each line of three files and put it in an 2D array (3 rows and 50 lines).
    My goal is to print this array on the VI's panel in a Table or in a Multicolon Listbox. How to do this? In the While loop or out?
    I use Labview 6i.
    Thanks for your help

    Hi,
    I don't see any problems. I suppose that you can get a 2D array of strings from files.
    Now there are three solutions.
    1. Use of Arrays.
    Right-click on the wire with your 2D array and select "Create->Indicator" from pop-up menu. Now you have a 2D array on the front panel which will show you your data.
    2. Use of Tables.
    Select table control from "Controls->List&Tables". Paste it on the front panel of your vi. Right-click on it and select "Change to indicator" from pop-up menu. Then wire this indicato to your 2D array in the block diagram.
    3. Use of Multicolumn listboxes.
    Paste the multicolumn listbox to the front panel. On the block diagram right-click on it and select "Create->Property node" from pop-up menu. The property node of your control will appea
    r in the diagram. Right-click on it and change property to "Item Names" By selectring "Properties->Item Names" from pop-up menu. Now Right-click on the property node once again and select "Change to write" or "Change all to write" to toggle your property into write mode. Then wire your 2D array to this property node.
    The example is attached.
    Good luck.
    Oleg Chutko.
    Attachments:
    Tables.vi ‏26 KB

  • Building 2D array in a while loop

    I'm trying to build an array from hex data received from a serial device(using VISA) inside a while loop.  Can I take the hex string(262 bytes long) and write it into the first element of an array?  Everytime the loop is executed the next hex string  I would like to store  it into the next element of the array. Can someone give me some hints on how to get started or a basic vi that outlines building an array of this type in a while loop.  Thanks. 

    Where is the 2D aspect of this? What you're describing sounds like a 1D array, and you can just use auto-indexing to do this.
    To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
    Message Edited by smercurio_fc on 04-11-2008 04:07 PM
    Attachments:
    Example_VI_BD2.png ‏2 KB

  • Stopping while loop after last element of 2d array is passed through

    I posted something similar to this before, but what I got didn't work.  So this time I'll try to be more clear with what I am trying to do.  What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment.  I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after  the last element of the array is indexed.  I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running.  What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change.  Any ideas?
    Thanks 

    I am trying to run a measurement using labview to control different instruments.  The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint.  So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint.  What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running.  I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.

  • Is it possible to have one while loop in another while loop

    Is it?

    Well, actually there are several possibilities:
    1. You right click the orange square where the double value gets out of the loop and select "enable indexing". This results in an array of all values you get while this inner loop is running.
    2. You add a shift register to the outermost loop and use the "build array" function after the inner while loop. This results in an array of the last value after the inner while loop has stopped.
    3. You combine both ways described above. Then you get a 2D-array.
    You can see this in the attached vi. In every case you have to be aware of what happens with the memory. In case 2 and 3 the array grows steadily. This could leed to problems, so you have to take care to empty it, if possible.
    Now it depends on what kind of data you need.
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    BuildArray.vi ‏16 KB

  • Another novice question...I opened a file used "Concatenate String" to write to file creating headers and so forth...a "While Loop" routine is m

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juBefore the loop the "Concatenate String" peforms the following... line1 col.1 in an excel file is (Tester then Line1 col.2 (the testers name appears) next is a end of line. Then Line2 col.1 is (DATE)header then col.2(TIME)header then col.3(throttle voltage output)header then col.4(MAX VOUT)header then col.5(MIN VOUT) as i said this is perform before the loop with no pr
    oblem. Next during the "While Loop" the actual information for the DATE,TIME,Throttle voltage output,are inserted into Line 3 under the associated header with no problem. What I need to do is wait until the "While Loop" has completed to then store the MAX/MIN, but I can't seem to get the information to end up under the associated header. What do I need to set/use to accomplish this task? Thanks I've attached an excel spread sheet to give an example of where I need the values to be stored.
    Attachments:
    test1.txt ‏1 KB

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juThis can become hard depending on how much data you will be writing. If you could wait and write the data all at one at the end of the while loop it becomes easier. The problem is that when you write a file it writes it in rows of data not columns. I will attach an example (LabVIEW 6.0) that demonstrates how to do this. It is a hard to describe in text. Basically I create the new columns of data and write empty strings to them on each iteration of the while loop except for the first iteration. The first iteration I write a Max? and Min? into the column information. After the while loop is completed I search the array for Max? and Min? and replace it with the appropriate min and max values.
    Attachments:
    append_column.vi ‏47 KB

Maybe you are looking for