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

Similar Messages

  • Why array index starts from 0(zero)?

    Hi,
    I want to know, why array index starts from 0?

    There is also another historical reason for this which often gets overlooked.
    In machine language some instruction sets have a branch-on-zero instruction which would always come in very handy for saving CPU time in most kinds of loop.
    These days you're used to forming your loops just as you like, which you could then, but a construct like
    public class arraycopy {
         public static void main(String[] args)
              final int arraysize = 10;
              int[] i = new int[arraysize];
              int x;
              for (x = 0; x < arraysize; x++)
                   i[x] = 25;
    }effectively, each time the loop check is done, it compares i with arraysize and breaks if the condition fails. This program translates to...
    LDA #$25
    LDX #$00
    LOOP STA $0200,X // <---- Note $0200 = arbitrary array location + X.
    INX
    CPX #$0A
    BNE LOOP
    In machine language (OOPS programmers will notice that the machine-language program is shorter, 12 bytes long in fact and it also executes much much faster).
    Basically, the problem is, that CPX, the compare, takes time, almost 1/5 of the total execuation time, and in a small loop for a long array it eats clock cycles... and a couple of bytes (Tchoh!).
    So, you can save time by re-writing the same loop thus...
    LDA #$25
    LDX #$0A
    LOOP STA $01FF,X
    DEX
    BNE LOOP
    By writing the loop backwards and taking advantage of the machine language underneath (i.e. the Real executable part of the program), you write a program that does exactly the same thing as the first example and is smaller and faster and easier to read. In fact the program takes 10bytes of memory. In machine-code you can place a complete working program in the amount of memory space it now takes you to store two double floats... now that's progress for you! : )
    Python does it, C does it and I have been bemoaning the fact that Java doesn't ever since I began using it. I want to be able to start a loop:
    while (x--)
    For those who know the rule that all non-zero numbers are true, there is a multitide of new choices!
    Join the revolution at
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6350717
    : )

  • Child tag initializer for type 'Array' may not be empty?error.

    hey,
    I imported this file from illustrator into catalyst. WE assume the error is caused by the filters tags but we can't delete them in the code view. The project is unable to run with this error. Is there a way to resolve this?

    Hey,
    I am also getting this error message and reads: "Errors (1 item) Child tag initializer for type 'Array' may not be empty. There is no way to edit anything in Code view, and I've been working this project for a little while. Imported items from Photoshop CS4. What to do? Thanks.

  • For loop in validation not working

    Hi,
    I am trying to put validation on a tabularform, such that column1 is not greaterthan column2 value.
    begin
    apex_application.debug('start check');
    for i in 1..3 loop
    apex_application.debug('i='||i);
    if apex_application.g_f05(i) < apex_application.g_f06(i)
    then
    return true;
    else
    return false;
    end if;
    end loop;
    end;could not figure out why the loop is not workinng. it is taking only 1st value i.e here "i" takes only value "1" then it checks the condition and later exists, doesnot check for the next row.
    any Idea..,!!!
    Help Me.
    Thanks,
    Little Foot

    Little Foot wrote:
    Hi,
    I am trying to put validation on a tabularform, such that column1 is not greaterthan column2 value.
    \begin
    apex_application.debug('start check');
    for i in 1..3 loop
    apex_application.debug('i='||i);
    if apex_application.g_f05(i) < apex_application.g_f06(i)
    then
    return true;
    else
    return false;
    end if;
    end loop;
    end;could not figure out why the loop is not workinng. it is taking only 1st value i.e here "i" takes only value "1" then it checks the condition and later exists, doesnot check for the next row.
    any Idea..,!!!
    Help Me.One way or another the code returns a value on the first iteration, which obviously always exits the loop at that point.
    (And it's \...\, not \...\)

  • Error CreateImage in for loop array

    Hi,
    I would like to dynamically create images inside a for loop. It dependent on the array_size that the sevlets will send. Snapshots of code:
    for (int i = 0; i < ARRAY_SIZE; i++)
    img[i] = Image.createImage("\"/nike" + (i+1) + ".png\"");
    }Error:
    java.io.IOException
         at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
         at javax.microedition.lcdui.ImmutableImage.<init>(+20)
         at javax.microedition.lcdui.Image.createImage(+8)
         at SlidesCanvas.createImages(+138)
         at SlidesCanvas.<init>(+146)
         at ListSlides.commandAction(+113)
         at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
         at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
         at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
         at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
    Is this a known bug in CreateImage? Or am i doing it in a wrong way?

    Herlena
    I tried this, it works.
    for (int i = 0; i < ARRAY_SIZE; i++) {
        img[i] = img.createImage("nike" + (i+1) + ".png");
    Hope your problem is solved, Darryl

  • For Loop Function is not doing what I am intending to do

    In the following example, I am two loops. One upper loop and one inner loop. I have a counter named COPY NUMBER within upper loop. This counter is increasing everytime upper loop and inner loop executes. If the upper loop executes 2 times and inner loop executes 10 times. The counter value has to be 2. But in reality, I am getting the value 20.
    -------------------------------------------CODE START-------------------------------------------
    <?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,/ R5542565/Phase_1___Build_Work_File_S1/Detail_Line_1_Section_S2_Group/On_Payment_Terms_S3/Pages,1)?>
    <?xdoxslt:set_variable($_XDOCTX, ‘copy_number’, xdoxslt:get_variable($_XDOCTX, ‘copy_number’) + 1)?>
    OUTERLOOP START
    COPY NUMBER: <?xdoxslt:get_variable($_XDOCTX,'copy_number')?>
    <?for-each@section:/R5542565/Phase_1___Build_Work_File_S1/Detail_Line_1_Section_S2_Group/On_Payment_Terms_S3?>
    INNER LOOP START
    Title: <?Dynamic_Report_Heading_ID299?>
    Invoice Number: <?Invoice_Number_ID27?>
    <?if: xdoxslt:get_variable($_XDOCTX,'copy_number')=1?>ORIGINAL<?end if?>
    <?if: xdoxslt:get_variable($_XDOCTX,'copy_number')=2?>DUPLICATE<?end if?>
    INNER LOOP FINISH
    <?end for-each?>
    OUTERLOOP FINISH
    <?end for-each?>
    -------------------------------------------CODE END-------------------------------------------

    First of all, are you aware that Spry is a dead technology and the code you're wrestling with is over 7 years old and will not work with mobile touchscreen devices (essential in today's web world)?
    Even though it's included in older versions of Dreamweaver, Adobe formally abandoned Spry last year
    http://blogs.adobe.com/dreamweaver/2012/08/update-on-adobe-spry-framework-availability.htm l'
    Point being, few people will advise you to continue along this Spry path.
    You're better off investing your energy in a modern up-to-date menu system.
    Free ones try
    http://forums.adobe.com/message/5070444
    If funds will allow then try
    http://www.projectseven.com/products/menusystems/pmm3/index.htm

  • Script code sample for looping  through the records from xml data file in formCalc script

    Hi
       I have a xml data file which contains a sequence of repeating applicant data like given below
                       US
                       II
                       CEO
                       Mr
                       111111111
                       0000000111
                       GuarantorA
                       111
                       IN
                       11111
                       WILLIAMS1
                       R3
                       KENNETH1
                       City1GU
                       PA
                       1934-03-14
                       [email protected]
                       GU
                       R
                       113 Lazlo LaneCA
                       Suite 3500CA
                       OaklandCA
                       TX
                       11345
                       AL
    I want to assign a textfield with a value based on the value of coap_flag.
    So i need to loop through all the record and check the value of coap_flag and then assign the textfield a value based on that.
    I am new to Adobe livecycle...Please help me how it can be done.
    I have developed something like this
    foreach Item in ($record.applicant[*].coap_flag) do
    test.value=Item
    if(test.value=="MA")then
    concat($record.applicant.first_name,$record.applicant.middle_name)endif
    endfor

    Using the data you posted in the forum, I copied it a couple of times to give multiple records and used this code to extract the different values that you wanted. I had to wrap it in a <root> node that I called root (to make it valid XML). In my case I wrote the extracted values to a field, but in your case you can do whatever you want with them. Note that this was done in javascript:<br /><br />var currentElement;<br />var obj;<br /><br />//Get the nodes below the root node in the dataDom<br />obj = xfa.datasets.data.root.nodes;<br /><br />//Set an initial value for the textField<br />TextField1.rawValue = "The values of the coap_flag are: ";<br /><br />//Loop through the nodes in the obj set <br />for (i=0; i< obj.length ; i++){<br />     //set the currentElement to the 1st child node<br />     currentElement = obj.item(i);<br />     //Check to see if it is an applicant node<br />     if (currentElement.name == "applicant"){<br />          //It is an applican, now find the coap_flag node value and write it to the text field<br />          TextField1.rawValue += "\n" + xfa.resolveNode("xfa.datasets.data.root.applicant[" + i + "]").coap_flag.value;<br />     }<br />}

  • 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

  • How do you loop an album in itunes 12 - in my version the icon for looping continuously is not there anymore - why did they mess with something so dang basic - i hate them

    how do you loop an album in itunes 12

    Hi johndoylin,
    Welcome to the Support Communities!  In iTunes 12, the loop feature is found in the menu bar:
    Play songs - iTunes Help
    http://help.apple.com/itunes/mac/12/#/itns2989
    Repeat all songs in the current view (for example, a playlist): Choose Controls > Repeat > All.
    Repeat the currently playing song: Choose Controls > Repeat > One.
    Turn repeat off: Choose Controls > Repeat > Off.
    Here is some additional information about iTunes 12:
    Using the new iTunes - Apple Support
    http://support.apple.com/en-us/HT203128
    Happy Holidays!
    Judy

  • 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.

  • Real-time updates of an XY graph with a 2D array (x,y) inside a for-loop

    Hi all,
       I am new to this forum, and relatively new to LabView (I've used TestPoint in the past), and I have a question. I have implemented a for-loop to grab data from an LCR meter (via GPIB) which becomes the Y data. The X data is calculated and tunneled into the for loop (although varies with incrementing 'i'). Anyhow, I am trying to store all of the data and keep the user updated throughout the test by plotting the XY Graph each iteration. Right now, the XY Graph plots one point at a time, so somehow the data I am appending to the 2D array (x,y data) is getting overwritten each itteration. How can I make it so that each new point is added to the array, making it bigger so that the data will be saved and so that the user will be able to see all the data in real-time on the graph as the test in running?
    Thanks
    P.S. I would post a screenshot, but I'm not sure how to upload here.

    Hey Mendeleev3104,
    There is an attachment section at the bottom of the post when creating or editing a post. You might want to use that to attach a picture of your code.
    None the less I will give a shot with some suggestions without viewing your code.
    You should look into using shift registers along with the Insert Into Array.vi to build an array of numbers. A good source of information for shift registers can be found in the For Loop and While Loop Structures help.
    Hopefully this helps!!
    Aashish M
    Applications Engineer
    National Instruments
    http://www.ni.com/support/

  • Interesting way to detect array index from mouse position

    Ever programmed something and then been surprised it works? This was the first time for me. Wrote a bit of code with the intention of identifying the array index clicked from the mouse position for use in a 'mouse down?' event and it worked first time. Then I went back and realised I had been half asleep and it doesn't even use the mouse position- but as if by magic it works!
    VI snippet below. For some reason LabVIEW modifies the array reference when I create a snippet, so you'll need to change that array reference for one pointing to array 2. <= Anyone able to raise a CAR against this?

    In the past I've used this VI.  I think it is quite similar to yours and I could probably simplify based on what you have done.  One thing my VI does is it tries to take into account the scrollbar size if one is being shown for the array.
    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.
    Attachments:
    Coordinates to Index.vi ‏20 KB

  • Is it possible to put property node inside for loop?

    I have created three separate property nodes (plot color) for my 3 XY graphs.
    Is it possible to have one property node, say plot_color_i and put this inside the for loop where i runs from 1 to N,
    where plot_color_1 would update XY Graph 1, plot_color_2 would update XY Graph 2, etc.?
    See the attached VI.
    Solved!
    Go to Solution.
    Attachments:
    XY Plot Example.vi ‏18 KB

    Yes.  Create an array of references of the XY graphs and have that auto-index into the property node in the For Loop
    Attachments:
    XYPlotExampleMOD.vi ‏18 KB

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to pause and stop two "for loops" in an event

    Hi
    The main menu runs first and then goes to reading menu. After "Start Reading" button is pressed, the reading process will take readings.
    1) During reading process, if the "Pause Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters do not reset. After the "Start Reading" button is pressed, the two "for loops" will continue to run.
    2) During reading process, if the "Stop Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters are reset. After the "Start Reading" button is pressed, the two "for loops" will run again.
    The attached two VIs are simplified my real application. Any help will be appreciated.
    Thanks
    Steve
    Attachments:
    Main Menu Test.vi ‏9 KB
    Reading Menu Test.vi ‏23 KB

    You can't have those loops inside of the event structure.  Currently, when you press the start button, the reading has to finish before the event case finishes.  This will prevent the stop can cancel buttons from being processed by the event structure.
    You need another loop that can recieve commands from the event loop.  Look up the Queued Message Handler.  That should get you a good start on the command process.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for