Hihow to insert 2 elements into 2D array?

Hi I had a hard time figuring out how to insert 2 elements into 2D arrays. 
I tried using replace and insert array functions but it does not work right way.
I am using LV7.1. See the pic below.
How do I insert elements in that way?
Pls advise
Clement

Well, "replace array subset" is not the right tool, because it keeps the size of the array constant. Insert into array only works for entire rows or columns.
You need a hybrid approach, because you want to insert elements at the beginning of column 1 while padding the remaining columns to the new lenght of column 1. This won't be efficient but there are plenty of ways to do that (here is one example with DBL arrays, should work equally well for string arrays as in your case).
How much flexibility do you need? Is it always at the beginning of the first column? Are the arrays huge (=is performance an issue)? Is this a rare operations or do you constantly need to do this (e.g. inside a loop).
In any case this seems like a rather arbitrary and somewhat silly operation. What is the practical purpose?
LabVIEW Champion . Do more with less code and in less time .
Attachments:
WeirdMerge.vi ‏21 KB

Similar Messages

  • How to insert elements into an array after each iteration of a for loop

    I am new to labview and working on an application where I am supposed to store an element into an array (without overwriting) after each iteration in a for loop. I have tried using Build Array Function keeping the indicator outside the for loop and played with indexing but didn't work. Please suggest me an idea how to do it.
    Thanks
    Solved!
    Go to Solution.

    Thank you for your suggestion.Here is my actual application attached . In the first image, a difference in time is evaluated and an enum const of insert into array is passed to the shift register where it takes to Insert element into array phase (Second image). I need to enter the time difference into an array after every loop iteration. Please have a look and could you let me know where I am mislead.
    Attachments:
    Image 1.JPG ‏88 KB
    Image 2.JPG ‏71 KB

  • Insert element into array (manually)

    Hello,
    I have an issue with the insertion of elements into an array. Here's the situation;
    - I've declared an array of strings as a local variable (let's say a 10-element array)
    - All the fields of the array have been filled with strings.
    - I would like to insert a new element into the array (for example at index 3)
    When I go to the "bounds" property and increase the array's bounds, the new element is added at the end of the array. Is there a means to insert the new element in any other position ?
    Thanks
    Zouz

    If you call a PropertyObject.SetVal<DataType>ByOffset() method, you can pass PropOption_InsertElement to the options parameter.

  • Insert element into array problem

    Hi,
    I have problem about how to insert value into an array. here is one section, could anyone help me to insert input value into array and delete the first value in the array. Gap means to fill in code
    void Ins(String name)
    // Insert name or increment its multiplicity.
    // If the bag is full remove the oldest entry.
    int i; // Running index on BagName
    int target; // if target < n then name.equals(BagName[target]);
    // else target == n
    Date EntryDate; // Current date and time
    // Get current date and time
    EntryDate = new Date();
    BagDate[n] = EntryDate.toString();
    Mult[n] = n+1;
    BagName[n] = name;
    n++;
    // Search bag for name
    // Gap 2
    // Assertion: target < n => name.equals(BagName[target])
    // else target == n
    // Update Mult if target < n
    // Gap 3
    // Make room for and insert name if target not found
    } // Ins(String name)
    Message was edited by:
    sibojava
    Message was edited by:
    sibojava

    Do you have several accounts?
    See this thread, it's the same question:
    http://forum.java.sun.com/thread.jspa?threadID=5143232
    Kaj

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Adding next element into an array

    I can manage to add the first element as I want in a for loop, however, the next element simple overwrites the index array element. I would like it to add the next element to the next space in the array.
    This is how I have declared it.
    private String stuff[];
    This is it initialised, with 10 as an example.
    Stuff = new String[10];
    This is inside a method with a string tokenizer ("st").
    while(st.hasMoreTokens())
    boolean comparsion = enter.equals(st.nextToken());
    if(comparison == true)
    stuff(i) = st.nextToken(); <<the brackets next to stuff () are meant to be [] but forum formats to italic
    I am trying to add values that match what is entered in a parameter (enter is the parameter variable) against the tokens in a file. It seems to add the first match in the array and then if run again it replaces this a new match and is not added as the second element. Any help much appreciated.
    Thanks.

    Use the code tags as follows next time:
    your codeThank you.
    Your problem is you do not increment i;
    stuff = new String[10];
    int i = 0; // declare and initialize i
    while (st.hasMoreTokens())
      boolean comparsion = enter.equals(st.nextToken());
      if (comparison) // no need to == true
        stuff[i] = st.nextToken();
        i++:  // increment i
    }

  • Problems with inserting elements into vectors

    Hi,
    I have a problem with the setElementAt() method for vectors.
    I want to initialise a vector that is same size as a previous vector declared in my program and insert float 0.0 in all the positions.
    The code below is a for loop to do just this where count is the size of the previous vector.
    for(int i=0;i<count; i++)
                   vLargest.setElementAt(zero,i);
              }i have declared zero as a float
    float zero = 0.0f;
    the error that i'm getting is that it that the vector cannot be applied to a float.
    Can anybody tell me what i'm doing wrong?
    Thanks

    Yes you need to store Objects in your Vector not primitives.
    float is not an Object it is a primitive. But Float is an object.

  • Need help with inserting element into a grid

    Hi,
    I'm trying to add an element in a 11x11 grid, but the program stop and give me 2 error (identified in the code) and I have no idea on what is wrong with those line. If anyone have any idea, suggestion or an other way to do this, I could use some help.
    Thx
              for (int i = 0; i != NUMBER; ++i) {
                      int row = 2 + (int)(Math.random() * 10);
                   int col = 2 + (int)(Math.random() * 10);
                   int nb = 0 + (int)(Math.random() * 2);
                   boolean horizontal = true;
                   if (nb == 1)
                        horizontal = false;
                   if (horizontal) {
                        if (row <= element.getDimension()) {  // error at this line
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row + j][col]     = "X";
                        else {
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row - j][col]     = "X";
                   if (! horizontal) {
                        if (col <= element[i].getDimension()) { // error at this line
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row][col + j]     = "X";
                        else {
                             for (int j = 0; j != element[i].getDimension(); j++) {
                                  grid[row][col - j]     = "X";

    My error is : Exception in thread "main" java.lang.NullPointerException
    at Grid.<init><Grid.java:67>
    at PrincTp1.main<PrincTp1.java:24>
    That's my class element
    public class Element {
    // Attributs
         private int dimension;
         private boolean horizontal;
         private String name;
         private int row;
         private int col;
    // Constructor
         public Element(int dimension_, String name_) {
              dimension = dimension_;
              name = name_;
         public Element() {
    // getter/setter
         public void setDimension(int dimension_) {
              dimension = dimension_;
         public int getDimension() {
              return dimension;
         public void setHorizontal(boolean horizontal_) {
              horizontal = horizontal_;
         public boolean getHorizontal() {
              return horizontal;
         public void setNom(String name_) {
              name = name_;
         public String getName() {
              return name;
         public void setLigne(int row_) {
              row = row_;
         public int getRow() {
              return row;
         public void setCol(int col_) {
              col = col_;
         public int getCol() {
              return col;
         }

  • Insert data into array

    I want to know if its possible to insert data into an array, but I wish to do it as I would in excel, by using the option of insert row.
    Is it possible to insert a value into an array in a specific row, so that all the other values after the one that was inserted are moved one row down?
    Please let me know how to do this, and if you could please provide some sample code, that would be great.
    Thanks!

    I tried using the array subset, but I still can't get the result that I want.
    What I want is to be able to add elements to the array, and that element should be added to a specific category (defined by one of the text rings).
    Example: in the category, I have the first one and in the elements (second text ring) I have the second one. The element that I will add will be in the 3rd position of the category that I selected. So if I have a category of DVDs, and in the items I have 2 brands (TDK, Maxell), and I will add Sony as the 3rd item in the second text ring that is being populated depending on the selection in the first text ring.
    How can I add items to the second text ring, so that they only appear in the category that I selected in the first text ring?
    Thanks in advance!

  • Can we include ArrayList into a array

    HI,
    i am newer to java.
    Can we include ArrayList element into an array,
    give the sample code.
    Regards,
    kumar

    Fine. But Here, all of my ArrayList elements are
    string.
    I have to assign all the ArrayList elements into the
    the array.
    Is it possible. give the sample code.Yes say your array list has all string elements here is how you do it...
    ArrayList<String> alist = new ArrayList<String>();
    alist.add("1");
    alist.add("2");
    alist.add("3");
    alist.add("4");
    alist.add("5");
    String arrayStrings[] = alist.toArray(new String[alist.size()]);
    NOTE: Works with J2SE 5.0 or above
    and for 5.0 below the below could be a solution.
    public static void main(String[] args){
    Test test = new Test();
    // Syntatically incorrect
    String[] s1 = new String(lst.size());
    // Would get a Type Cast Exception as ArrayList.toArray() returns Object[] not String[]
    s1 =lst.toArray();
    // and btb what test.toArray() do ??
    //s1 = test.toArray();
    }you may have to restructure it to
    public static void main(String[] args)
      Test test = new Test();
       int size = lst.size();
       String ArrayString[] = new String[size];
       Object k[] = list.toArray();
       for(int i=0 ; i < size; i++)
         ArrayString[i] = (String)k;
    Hope that might be the one...
    REGARDS,
    RaHuL

  • How to insert 1 element in 2D array?

    There is an example of how to replace element in 2D array, but I would like to insert (not replace), I use the insert element. it does not work for 2 D array.
    Attachments:
    find_and_map_defect_to_image736X554.vi ‏46 KB

    You need to tell more about what you want done. What exactly does it mean
    to insert into a 2D array? Are you inserting into the row or column or
    both? By that I mean to ask what parts of the array get their indices
    incremented. Then what should happen at the endpoints? If you insert a
    point into one row then that row will have one more element than the others.
    Should the last element in that row be lost or should the other rows get a
    zero appended?
    "trout00" wrote in message
    news:[email protected]..
    > There is an example of how to replace element in 2D array, but I would
    > like to insert (not replace), I use the insert element. it does not
    > work for 2 D array.

  • Deactivate "insert element before / remove element" in array

    Hello guys.
    It is possible to deacitvate "insert element before / remove element" function appears after right-click on a array in the frontpanel?
    "Description and Tip" should stay.
    Thank you.
    Alex
    Solved!
    Go to Solution.

    You can customize the right-click shortcut menu to remove some application items and keep others:
    Right-click on the array (and not on the array element!) in the front panel and select Advanced->Run-Time Shortcut Menu->Edit...
    This brings up the Shortcut Menu Editor:
     Change the drop-down control from "Default" to "Custom".
     Select the "???" line in the tree control on the left.
     on the right, change the Item Type from "User Item" to "Application Item -> Description and Tip..."
     It will automatically fill in the corrent Name and Tag.
     Save the rtm either into its own file or into the control.
     LV will automatically handle application items in the control, no event case needed.
     I sometimes find the "Copy entire menu" function of the shortcut menu pretty useful if I only want to disable a few items.
    http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/customizing_vis/#Customizing_Menus
    -Barrett
    CLD

  • How to add elements into java string array?

    I open a file and want to put the contents in a string array. I tried as below.
    String[] names;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
                    String item = s.next();
                    item.trim();
                    email = item;
                    names = email;
                }But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

    Actually you cannot increase the size of a String array. But you can create a temp array with the lengt = lengthofarray+1 and use arraycopy method to copy all elements to new array, then you can assign the value of string at the end of the temp array
    I would use this one:
    String [] sArray = null;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
        String item = s.next();
        item.trim();
        email = item;
        sArray = addToStringArray(sArray, email);
    * Method for increasing the size of a String Array with the given string.
    * Given string will be added at the end of the String array.
    * @param sArray String array to be increased. If null, an array will be returned with one element: String s
    * @param s String to be added to the end of the array. If null, sArray will be returned.(No change)
    * @return sArray increased with String s
    public String[] addToStringArray (String[] sArray, String s){
         if (sArray == null){
              if (s!= null){
                   String[] temp = {s};
                   return temp;
              }else{
                   return null;
         }else{
              if (s!= null){
                   String[] temp = new String[sArray.length+1];
                   System.arraycopy(sArray,0,temp,0,sArray.length);
                   temp[temp.length-1] = s;
                   return temp;
              }else{
                   return sArray;
    }Edited by: mimdalli on May 4, 2009 8:22 AM
    Edited by: mimdalli on May 4, 2009 8:26 AM
    Edited by: mimdalli on May 4, 2009 8:27 AM

  • How to put data into a array element in the BPEL

    Hi,
    I have a element in the WSDL which is of type Array. (i.e accepts unlimited data for the same element). How should i put a data into a array in the BPEL.
    Example:
    The below Example gives u an idea about wht iam asking:pasting a piece of my requirement:
    <s:element minOccurs="0" maxOccurs="1" name="parameters" type="tns:ArrayOfCSParameters" />
    <s:complexType name="ArrayOfCSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="unbounded"
    name="CSParameters" nillable="true" type="tns:CSParameters" />
    </s:sequence>
    </s:complexType>
    <s:complexType name="CSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="RevenueItem" type="tns:RevenueItem" />
    <s:element minOccurs="0" maxOccurs="1" name="AccountURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="0" maxOccurs="1" name="GroupURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="1" maxOccurs="1" name="Percentage" nillable="true" type="s:decimal" />
    </s:sequence>
    <s:attribute name="Version" type="s:decimal" use="required" />
    <s:attribute name="URI" type="s:string" />
    </s:complexType>
    Any suggestion is appreciated.
    Regards
    pavan

    You have 2 options i guess.
    Use the transformation and the for-each to construct the array-list
    or like Richard said, use a loop in bpel, assign in the loop an variable of element type="CSParameters" and append this variable to your variable with accepts the arraylist.

  • How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers? (history data from a chart)

    Hello,
    in my vi I have a chart with 5 Plots displaying measurement data.
    The user should be able to save all the history data from the chart at anytime. (e.g. the user watches the chart and some event happens, then he presses a "save"-button)
    I know, that I can read out the history data with a property node. That is not the problem. The problem is, how do I handle the data? The type of the history data is a 1-D array of cluster of 5 elements.
    I have to convert that data somehow into a 2 D-array of numbers or strings, so that I can easily save it in a text-file.
    How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers?
    I use LabVIEW 7.1
    Johannes
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Solved!
    Go to Solution.

    Gerd,
    thank you for the quick response and the easy solution.
    Look what I did in the meantime. I solved the problem too, but muuuch more complicate :-)
    And I have converted the numbers to strings, so that I can easily write them into a spreasheet file.
    Johannes
    Message Edited by johanneshoer on 04-28-2009 10:39 AM
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    SaveChartHistory.JPG ‏57 KB
    SaveChartHistory.JPG ‏57 KB

Maybe you are looking for

  • My computer crashed...how do i get my old library transferred to a new one?

    i had a desktop computer (a dell with windows XP) that was 7 years old and crashed. it has to have windows reinstalled. this means i'm losing everything on my hard drive. can i transfer what's on my ipod directly to my new computer, which is a dell l

  • Performance with txkWfClone.sh

    Hi list, According to Note: "Autoconfig Performance Issue Running txkWfClone.sh After Applying ATG_PF.H Rollups [ID 458443.1]" there is a performance problem with script txkWfClone.sh. Right now, I am running "perl adcfgclone.pl appsTier" command in

  • How to change menu bar in Korean to English in InDesigh CC

    Hi, I just installed free trial version of InDesign CC on my Mac. I don't know what I selected, but the menu bar shows in Korean which I can read it. However, I prefer to have menu bar in English. Does anybody know how to change it? Do I have to rein

  • Installing Solaris 10 On HP ML 350 G5

    I have a problem when installing solaris 10 on HP Proliant ML350 G5, it says no disks found, I have smart array controller E/200 from HP, i downloaded the driver and followed the steps for updating driver during installation of solaris 10, but i stil

  • Sequence conversion

    Hello: I am trying to convert a LabWindows/CVI sequence file to TestStand but I get warnings/errors when opening or running the sequence in TestStand. After converting the file I do a File->Open in the TestStand Sequence Editor and I get a "Open Sequ