Handling 2-D arrays

I have this 2-D array:
private int[][] board = {{0,5,0,0,0,0,0},
                         {0,0,0,0,0,0,0},
                         {0,0,0,0,0,0,0},
                         {0,0,0,0,0,0,0},
                         {0,0,0,2,0,0,0},
                         {0,0,1,2,2,2,0}};1. How do you get the index of element with value 5?
2. How do you get a 2-D array's length/height/width/whatever?

What I mean is, 5 isn't unique to that "cell"; there
can be many 5's. For example, I know that 5 belongs
to row 0, col 1. But how do I show it in the program?Depends what you mean by "show". That's up to you. But to find every 5, simply do as suggested: Run nested for loops, test each element for == 5, and if it matches, then your loop indices tell you which element it is.
Here's a 1D example. Expanding to 2D is left as an exercise for the reader.
for (int ix = 0; ix < arr.length; ix++) {
  if (arr[ix] == 5) {
    System.out.println("Index " + ix + " contained 5");
}

Similar Messages

  • Event Handling in an Array of TextField

    I have created an array of textfields (say t[0],t[1],t[2],....) and want to implement the FocusListener Interface.
    I want to use the method focusLost() to get the name of the textfield in the form t[x] whenever the event occurs in the field.
    Can I do it? if yes, how?
    p.s.- getting back the array index is most important.

    I think it's possible.
    Extend the TextField class. Add 2 new methods, setID() and getID() and a new int field named ID. Change your code so that the array of TextFields is an array of your new class. When you construct the class, set the value of ID to be the same as the index.
    In the focusLost() method, use getSource() of the FocusEvent to get the Object that generated the event and cast that Object to the new class. Use the getID() method to get the index.
    I can think of other ways that use a similar approach.
    A different approach would not require extending TextField. Use getSource() to get a reference to the textfield and loop thru the textfield array comparing the reference to the array element until you have a match.

  • How to handle ever expanding array?

    Hi,
    I'm looking for help with a temperature control experiment...
    I have a program to aquire data from 24 channels through a while loop.
    I am displaying the data in a waveform graph. Currently, I am using
    shift registers and build array to add new data to the graph every time
    through. This worked fine while I was prototyping the hardware, but now
    I'd like it to run for days on end; as everyone can imagine, the array
    keeps getting bigger and the build array function keeps hogging memory
    until the whole thing crashes.
    I'm guessing that I should be writing the data to a file every so
    often, which would keep the size manageable, and would allow me to know
    the size of the array and could use other opperations rather than build
    array. The array would need to stay pretty small so the write operation
    didn't slow down the loop too much. The program is pretty slow, since
    I'm limited in how quickly I can
    change temperatures. Currently, I go through all 24 probes about every
    2.5 seconds (this is set just by how long it takes the routine to read
    each temperature and calculate the control parameters). If it takes a
    little bit longer each time through, that's not a huge problem, but a
    big pause every so often would make the control routine behave oddly.
    What the save-to-file option takes away, however, is the ability to
    walk up to the machine in the morning and see at a glance how well it
    regulated the temperature during the night. I've thought about keeping
    some reduced set of the data (every minute or so) to give me a
    low-frequency glance at the data, but it seems like this will simply
    postpone the inevitable memory loading. I don't know if I could have a
    separate program that opened up the files that the control routine
    wrote, but this would probably be too much for the poor old PII machine
    that is running this.
    Does anyone have a simple solution to this probelm? Failing that, a
    complex solution might do, although it might get beyond my programming
    abilities.
    I only have LV 6.0, so I can't see examples saved for versions later than this.
    Thanks for any suggestions.
    cheers,
    mike

    Mike,
    Writing data to an array every so often is definitely what you want to do. Then if power fails or the program shuts down for some reason, the data to the last save is still in the file. At the 2.5 second sample rate you only get ~35000 points per channel per day, so data files will not get too large. Decide how often to write by how valuable the data is: What is the penalty for losing data for the last minute, hour, day...?
    Another point is that the panel display only occupies a few hundred pixels in each direction. Plotting more points than that is meaningless. If you plot one point per minute you will have 1440 points per day (per channel). You could always show the most recent 24 hours using a circular buffer. With more programming effort, you could keep previous days plots available for selection by the user or read them back from the file.
    Lynn

  • Exception handling in sorting arrays

    Hi all, I have a problem with the use of the built in java sort fo arrays. My program works on an array with 4 or 5 entities. When I run it in some folders it works but not in others. I get the following error after compilation, where "ResultData" is the class of array to be sorted:Exception in thread "main" java.lang.NullPointerException
    at ResultData.compareTo(TextEdit.java:1215)
    at java.util.Arrays.mergeSort(Arrays.java:1064)
    at java.util.Arrays.mergeSort(Arrays.java:1071)
    at java.util.Arrays.mergeSort(Arrays.java:1072)
    at java.util.Arrays.mergeSort(Arrays.java:1071)
    at java.util.Arrays.mergeSort(Arrays.java:1071)
    at java.util.Arrays.mergeSort(Arrays.java:1071)
    at java.util.Arrays.sort(Arrays.java:1014)
    at java.util.Collections.sort(Collections.java:78)
    [\code]Can any one give a suggestion?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Here is the code for the class "ResultData"class ResultData implements Comparable
         String file1;
         String file2;
         double var, var1, var2;
         public ResultData(String f1,String f2,double v, double x, double y)
                   file1= f1; file2=f2;
                   var=v; var1=x; var2=y;
         public String getFile1Name()
              return file1;
         public String getFile2Name()
              return file2;
         public double getVar()
              return var;
         public double getVar1()
              return var1;
         public double getVar2()
              return var2;
         public String toString()
              return file1+"          "+file2+"          "+var+"          "+var1+"          "+var2;
           public int compareTo(Object o)
              ResultData r= (ResultData)o;
              double result = this.getVar()- r.getVar();
              if (result < 0.0)         return -1;
              else if(result > 0.0)     return 1;
              else return 0;
    } // ends class ResultData

  • How to handle a second array?

    Hi all,
    I tried to add in a second array, but I got an error that said "unreachable code" for each aspect I entered using array b(the second array).
    // IntegerSet.java
    public class IntegerSet {
      private int [] a;  // holds a set of numbers from 0 - 100
      private int [] b;  // also holds numbers 0 - 100
      public IntegerSet () {
        // an empty set, all a[i] are set to 0
        a = new int [101];
        b = new int [101];
      // A constructor that copies from an existing set.
      public IntegerSet (IntegerSet existingSet) {
        a = new int [101];
        b = new int [101];
        for(int i=0; i<a.length; i++)
          a[i] = existingSet.a;
    for(int i=0; i <b.length; i++)
    b[i] = existingSet.b[i];
    public void deleteElement(int i) {
    if ((i >= 0) && (i < a.length))
    a[i] = 0; // set to 1
    if ((i >= 0) && (i < b.length))
    b[i] = 0;
    public void insertElement(int i) {
    if ((i >= 0) && (i < a.length))
    a[i] = 1; // set to 1
    if ((i >= 0) && (i < b.length))
    b[i] = 1; // set to 1
    public boolean isSet(int i) {
    return (a[i] == 1);
    return (b[i] == 1);
    // The union of this set and another set
    public IntegerSet unionOfIntegerSets(IntegerSet otherSet) {
    IntegerSet newSet = new IntegerSet(this);
    // newSet is now a copy of the current set. Next we want to union with set a
    for(int i=0; i<a.length; i++) {
    if (otherSet.isSet(i))
    newSet.insertElement(i);
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i))
    newSet.insertElement(i);
    return newSet;
    // The intersection of this set and another set
    public IntegerSet intersectionOfIntegerSets(IntegerSet otherSet) {
    IntegerSet newSet = new IntegerSet(this);
    // newSet is now a copy of the current set. Next we want to intersect with set a
    for(int i=0; i<a.length; i++) {
    if (!otherSet.isSet(i))
    newSet.deleteElement(i);
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i))
    newSet.deleteElement(i);
    return newSet;
    // return true if the set has no elements
    public boolean isEmpty() {
    for (int i=0; i<a.length; i++)
    if (isSet(i)) return false;
    return true;
    for (int i=0; i<b.length; i++)
    if (isSet(i)) return false;
    return true;
    // return the 'length' of a set
    public int returnLength() {
    int count = 0;
    for (int i=0; i<a.length; i++)
    if (isSet(i))
    count++;
    for (int i=0; i<b.length; i++)
    if (isSet(i))
    count++;
    return count;
    // Print a set to System.out
    public void setPrint() {
    System.out.print("[Set:");
    if (isEmpty())
    System.out.print("---");
    for (int i=0; i<a.length; i++) {
    if (isSet(i))
    System.out.print(" " + i);
    for (int i=0; i<b.length; i++) {
    if (isSet(i))
    System.out.print(" " + i);
    System.out.print("]\n");
    // return true if two sets are equal
    public boolean isEqualTo(IntegerSet otherSet) {
    for(int i=0; i<a.length; i++) {
    if (otherSet.isSet(i) != isSet(i))
    return false;
    return true;
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i) != isSet(i))
    return false;
    return true;
    // Small test program to verify that IntegerSet works!
    public static void main (String [] args) {
    IntegerSet smallEvens = new IntegerSet();
    IntegerSet smallOdds = new IntegerSet();
    for (int i=0; i < 101; i++)
    if ((i % 2) == 0)
    smallEvens.insertElement(i);
    else
    smallOdds.insertElement(i);
    System.out.print("smallEvens: ");
    smallEvens.setPrint();
    System.out.print("smallOdds: ");
    smallOdds.setPrint();
    IntegerSet union = smallEvens.unionOfIntegerSets(smallOdds);
    System.out.print("union: ");
    union.setPrint();
    IntegerSet intersection = smallEvens.intersectionOfIntegerSets(smallOdds);
    System.out.print("intersection: ");
    intersection.setPrint();
    // Output:
    // smallEvens: [Set: 0 2 4 6 8]
    // smallOdds: [Set: 1 3 5 7 9]
    // union: [Set: 0 1 2 3 4 5 6 7 8 9]
    // intersection: [Set:---]
    I'm guessing I probably put the braces wrong or something. Any ideas on how to fix this? I appreciate any help given. Thanks.

    All right, I edited part of the code, and put in comments to where the error occurs.
    public class IntegerSet {
      private int [] a;  // holds a set of numbers from 0 - 100
      private int [] b;  // also holds numbers 0 - 100
      public IntegerSet () {
        // an empty set, all a[i] are set to 0
        a = new int [101];
        b = new int [101];
      // A constructor that copies from an existing set.
      public IntegerSet (IntegerSet existingSet) {
        a = new int [101];
        b = new int [101];
        for(int i=0; i<a.length; i++)
          a[i] = existingSet.a;
    for(int i=0; i <b.length; i++)
    b[i] = existingSet.b[i];
    public void deleteElement(int i) {
    if ((i >= 0) && (i < a.length))
    a[i] = 0; // set to 1
    if ((i >= 0) && (i < b.length))
    b[i] = 0;
    public void insertElement(int i) {
    if ((i >= 0) && (i < a.length))
    a[i] = 1; // set to 1
    if ((i >= 0) && (i < b.length))
    b[i] = 1; // set to 1
    public boolean isSet(int i) {
    return (a[i] == 1 && b[i] == 1);
    // The union of this set and another set
    public IntegerSet unionOfIntegerSets(IntegerSet otherSet) {
    IntegerSet newSet = new IntegerSet(this);
    // newSet is now a copy of the current set. Next we want to union with set a
    for(int i=0; i<a.length; i++) {
    if (otherSet.isSet(i))
    newSet.insertElement(i);
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i))
    newSet.insertElement(i);
    return newSet;
    // The intersection of this set and another set
    public IntegerSet intersectionOfIntegerSets(IntegerSet otherSet) {
    IntegerSet newSet = new IntegerSet(this);
    // newSet is now a copy of the current set. Next we want to intersect with set a
    for(int i=0; i<a.length; i++) {
    if (!otherSet.isSet(i))
    newSet.deleteElement(i);
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i))
    newSet.deleteElement(i);
    return newSet;
    // return true if the set has no elements
    public boolean isEmpty() {
    for (int i=0; i<a.length; i++)
    if (isSet(i)) return false;
    return true;
    for (int i=0; i<b.length; i++) // unreachable statement
    if (isSet(i)) return false;
    return true;
    // return the 'length' of a set
    public int returnLength() {
    int count = 0;
    for (int i=0; i<a.length; i++)
    if (isSet(i))
    count++;
    for (int i=0; i<b.length; i++) // unreachable statement
    if (isSet(i))
    count++;
    return count;
    // Print a set to System.out
    public void setPrint() {
    System.out.print("[Set:");
    if (isEmpty())
    System.out.print("---");
    for (int i=0; i<a.length; i++) {
    if (isSet(i))
    System.out.print(" " + i);
    for (int i=0; i<b.length; i++) {
    if (isSet(i))
    System.out.print(" " + i);
    System.out.print("]\n");
    // return true if two sets are equal
    public boolean isEqualTo(IntegerSet otherSet) {
    for(int i=0; i<a.length; i++) {
    if (otherSet.isSet(i) != isSet(i))
    return false;
    return true;
    for(int i=0; i<b.length; i++) {
    if (otherSet.isSet(i) != isSet(i))
    return false;
    return true;
    // Small test program to verify that IntegerSet works!
    public static void main (String [] args) {
    IntegerSet smallEvens = new IntegerSet();
    IntegerSet smallOdds = new IntegerSet();
    for (int i=0; i < 101; i++)
    if ((i % 2) == 0)
    smallEvens.insertElement(i);
    else
    smallOdds.insertElement(i);
    System.out.print("smallEvens: ");
    smallEvens.setPrint();
    System.out.print("smallOdds: ");
    smallOdds.setPrint();
    IntegerSet union = smallEvens.unionOfIntegerSets(smallOdds);
    System.out.print("union: ");
    union.setPrint();
    IntegerSet intersection = smallEvens.intersectionOfIntegerSets(smallOdds);
    System.out.print("intersection: ");
    intersection.setPrint();
    // Output:
    // smallEvens: [Set: 0 2 4 6 8]
    // smallOdds: [Set: 1 3 5 7 9]
    // union: [Set: 0 1 2 3 4 5 6 7 8 9]
    // intersection: [Set:---]

  • How to handle massive array operations

    Hi!,
    We are working with large arrays of the order of 5000 x 100000 (rows x col).
    We wish to perform typical array operations like replace subset, indexing, rotating and addition.
    Our questions:
    1) How do we work with this array within the same VI without creating indicators or controls. Wiring, we understand, is an option but then the wires will clutter our screen.
    2) How do we pass/retrieve this array data to/from sub-VIs without creating indicators or controls.
    3) What the fastest recommended methods of handling such large arrays.
    4) Our array will be either Boolean or U8. Will both data types give similar speed results?
    5) When using the replace subset function, can the subset be same dimension as original array?
    6) Can we rotate a particular row within a 2D array? As of now, we extract the row as 1D, rotate and then replace the original row with rotated row.
    Any ideas/suggestions (specific to array handling) to help speed our VI will be highly appreciated.
    We are using LV 7.1 on Win2000
    Thanks,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

    Saverio, Joe, Jason and Benoit - Thanks!
    Reply to Saverio's inputs:
    (1) Not sure what you mean by this. If you need to work with that data in the same VI you use wires - that's the most efficient way of doing it. Are you thinking about local variables or something?
    No, we avoid locals like birdflu! What I meant was how do I carry data from one part of my block diagram (BD) to another without using wires (because wires clutter the block diagram)? Is there no variable/container which will hold data without it being a control/indicator? Some of my front panels will be displayed. In such VIs, the moment I use a control/indicator in the BD to "hold" my data, my speeds drop.
    (2) OK
    (3) OK
    (4) LabVIEW stores Booleans as 8-bit data. You should choose the one that makes more sense for your application.
    U16 makes most sense.
    U8 also does the task, only catch is at the end I need to convert the array into U16 for the last operation to happen (all elements in a col are added; thus final array is 1D row array).
    I would use Boolean ONLY if it gives significant speed gains over U8 (I will need to convert Boolean to U16 at the end).
    Any inputs/ideas?
    (5) OK
    (6) You will need to be a little more specifc about this one, though I suspect the Transpose 2D Array function coupled with the Replace Array Subset is what you're looking for.
    Lets say the first row of my 2D array has 5 elements, which are 3 6 12 8 1. I want this to become 12 8 1 3 6. In effect I left rotated my first row my two positions.
    Rgds,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

  • Array/buffer handle

    Hi,
    I am trying to program a DT9834 data translation board for continuous analog input operation. I am using its ActiveX (DTx-EZ) in Labview 8.5. I should create an array/buffer and pass its handle to ActiveX's queue property. How can I get the handle of the array that I created?
    Thanks for comments and help.

    The method for creating the DLL is outside of LabVIEW so you would need to look at the documentation for whatever compiler you choose to use. Visual Studio is the most prevalent, for better or for worse.
    There are several documents in the NI Knowledge Based on creating DLLs in Visual Studio. Here's a couple:
    Using Existing C Code or a DLL in LabVIEW
    Writing Win32 Dynamic Link Libraries (DLLs) and Calling Them from LabVIEW (a bit old, but still useful). 
    There's also an extensive example that ships with LabVIEW. Search the Example Finder for "dll". 
    There's also an entire section in the LabVIEW Help (Fundamentals -> Calling Code Written in Text-Based Programming Language)

  • What's the maximum size of an array in labview? LV run out of memory

    I want to create a 1D array of 40M element of Double: so I use Initialize Array, element is double 1, dimension size is 40M (and put a Sum at the end so as to make sure lv do attempt to create that array). Supposed this only need 320M of memory, and my system has over 1G free memory available as shown in Task Manager, but when Labview runs this VI, it tells me "Not enough memory to complete this operation" "Labview: memory is full, top level VI is stopped at Initalize Array", so it seems LV is unable to handle such an array, even if there is apparently more than enough free memory in the system.
    Does anyone know why labview fails to allocate memory for this VI? Anyway to solve this problem?

    This question has been asked many times. Have you tried to do a search? Arrays require contiguous memory. It doesn't matter if you have 40 GB of RAM. Unless you have a contiguous block for your array, the allocation will fail. You should read the chapter in the LabVIEW Help on managing large data sets. There are also a couple of KnowledgeBase articles.
    Of course, the obvious question is: why do you need to create such a large array in the first place?
    Message Edited by smercurio_fc on 01-18-2010 10:25 PM

  • Initializing an array of clusters in a CIN?

    I'm trying to write a CIN to connect to a mySQL database, retreive some information, and return it to labVIEW for display. The connection works perfectly using ODBC, but I'm having major trouble getting the information back to LabVIEW. I'm new to CINs and I'm still slightly confused as to how the different structures work. I want to return the data in an array of clusters (using struct names, a 'Set' of 'Records'). LV generated the structs, and I simply renamed some of the fields/names. The code I have so far works up to the point specified in the source below, when I try to initialize the array for data entry. I think what's throwing me off is the conplexity of my structures. Since it's an array of clusters, and not an array of say strings or integers, I'm getting confused. If anyone could help me out by telling me what's wrong with my code, and/or filling in the section of the while loop I'm rather clueless on.
    typedef struct {
    LStrHandle Number;
    LStrHandle SerialNumber;
    } Record;
    typedef struct {
    int32 dimSize;
    Record ptr[1];
    } Set;
    typedef Set **SetHdl;
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet);
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    // LV error code
    MgErr err = noErr;
    // ODBC environment variables
    HENV env = NULL;
    HDBC dbc = NULL;
    HSTMT stmt = NULL;
    // Connection options data variables
    UCHAR* dsn = malloc(SQL_MAX_DSN_LENGTH * sizeof(UCHAR));
    UCHAR* user = malloc(32 * sizeof(UCHAR));
    UCHAR* pass = malloc(32 * sizeof(UCHAR));
    UCHAR* num = malloc(16 * sizeof(UCHAR));
    // Query variables
    INT qlen;
    INT nlen;
    UCHAR colNumber[5];
    SDWORD colNumberSize;
    UCHAR* query;
    INT numRows;
    // ODBC return code storage
    RETCODE retcode;
    /** Prepare data from LV for C++ manipulation **/
    strcpy(dsn, LStrBuf((LStrPtr)(*(ConnectionOptions->DSN))));
    dsn[(*(ConnectionOptions->DSN))->cnt] = '\0';
    strcpy(user, LStrBuf((LStrPtr)(*(ConnectionOptions->Username))));
    user[(*(ConnectionOptions->Username))->cnt] = '\0';
    strcpy(pass, LStrBuf((LStrPtr)(*(ConnectionOptions->Password))));
    pass[(*(ConnectionOptions->Password))->cnt] = '\0';
    strcpy(num, LStrBuf((LStrPtr)(*Number)));
    // Program crashes here too, but that's the least of my concerns right now. Keep reading down.
    //num[(**Number)->cnt] = '\0';
    qlen = (int)strlen(
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '');"
    nlen = (int)strlen(num);
    query = malloc((qlen + nlen + 1) * sizeof(UCHAR));
    sprintf(query,
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '%s'\0);",
    num);
    // Prepare and make connection to database
    SQLAllocEnv (&env);
    SQLAllocConnect(env, &dbc);
    retcode = SQLConnect(dbc, dsn, SQL_NTS, user, SQL_NTS, pass, SQL_NTS);
    // Test success of connection
    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    retcode = SQLAllocStmt(dbc, stmt);
    retcode = SQLPrepare(stmt, query, sizeof(query));
    retcode = SQLExecute(stmt);
    SQLBindCol(stmt, 1, SQL_C_CHAR, colNumber, sizeof(colNumber), &colNumberSize);
    SQLRowCount(stmt, &numRows);
    //Program crashes on the following line. I get an error in LV saying something about an error in memory.cpp
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    (**RecordSet)->dimSize = numRows;
    retcode = SQLFetch(stmt);
    numRows = 0;
    while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    /* Need code here to retreive/create Records and put them in the array */
    retcode = SQLFetch(stmt);
    numRows++;
    SQLDisconnect(dbc);
    else
    // Free ODBC environment variables
    SQLFreeConnect(dbc);
    SQLFreeEnv(env);
    // Return LV error code
    return err;

    This looks incorrect:
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    Did you let LabVIEW generate the C file??
    When you pass an array of clusters to a CIN, what is passed is a handle to the array. You are declaring a pointer to a handle. I just did a test passing an array of clusters to a CIN. The C file looks like this (comments are mine):
    typedef struct {
    int32 Num1;
    int32 Num2;
    } TD2; // the cluster
    typeDef struct {
    int32 dimSize;
    TD2 Cluster[1];
    } TD1; // the array
    typeDef TD1 **TD1Hdl; // handle to the array
    CIN MgErr CINRun(TD1Hdl Array);
    Notice that it passes you a HANDLE, not a pointer to a handle.
    On this line:
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    If RecordSet is a HANDLE, then (*RecordSet) is a POINTER - you are passing a POINTER to a routine that expects a HANDLE.
    The line:
    (**RecordSet)->dimSize = numRows;
    Is also incorrect - if RecordSet is a HANDLE, then (*RecordSet) is a POINTER, and (**RecordSet) is an ARRAY, but you're asking it to be a pointer. (*RecordSet)->dimSize would be the size to fetch.
    Read the rules again on what is passed to CINs.
    I strongly suggest developing the interface first - the VI that calls the CIN. Put the CIN in place and let LabVIEW generate the initial C file.
    Then modify the code to do something simple with the input arguments, like fetch the array size, and put this number into an output argument. Something VERY basic, just to test the ins and outs. Debug this until all ins and outs are working.
    THEN AND ONLY THEN add code to do whatever work needs doing.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Change array index font size using VI scripting

    Hello All,
                         I have a array control in my front panel, I'm wondering is there any way to change that "array index" font size using VI scripting?
    Example:
    1. I have this array
    2. Manually I have changed the font size of the array in "Selection Font" panel as below
    3. Through VI scripting I'm able to control control font size, label font size.,.. But not the index font size. So it looks odd.
    4. I'm expecting to be modify this array as same as picture 1 through VI scripting.
    Note: It may not have any practical application, but some time it will be helpful for the programmers to make a quick drop. If anybody have any idea, please share.
    <Electro Sam>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

    Raven - you are right, Actually I'm looking for options to change the font size of the array index.
    Actually we have coding standard to follow. In that, all the front panel controls needs to be in Font size 14 and the size should be 25X120, so I'm trying to write a code which automatically converts the VI FP control sizes to be in standard size.
    I'm not only using one customer VI, I'm handling various customer VIs, so each one VI FP control sizes are different. So I'm developing this utility to standardize the VI's as per the guidelines we have.
    Except this array index most of the VI FP control elements I have handled, Only this array is troubling me.
    Appreciate your support guys, please share your thoughts.
    <ElectroSam>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • JNI - Passing an object containing an array field

    I need to pass an object to a native method. The object contains several int fields and a field that is an int array (contains 32 int).
    I have no problem with the int fields, but do not know how to access the int array field in the C code. What approach should be used to get/set values in the int array field?
    Any suggestions are appreciated.

    I have been reading up on the subject, but I guess I'm just an idiot. If all the answers were obvious from reading the specification then there wouldn't be much point to this forum.
    For int fields in the object passed to the native function I do the following to set the value:
    fid = (*env)->GetFieldID(env, cls, "intFieldName", "I");
    (*env)->SetIntField(env, myObj, fid, newValue);
    For a field that is an array of int, it seems that I can get the field ID as follows:
    fid = (*env)->GetFieldID(env, cls, "arrayFieldName", "[I");
    The "Get<Type>Field" and "Set<Type>Field" methods can be used for object, boolean, byte, char, short, int, long, float, double. Nothing specific here for array. Should I use the GetObjectField method, if so can the object field then be handled as an array? This is where I am missing something. I have experimented with using the SetIntArrayRegion method but this causes an exception - obviously missing a necessary step here. I am hoping someone here can provide guidance on what I am missing, what JNI functions I should be using, or refer me to the appropriate page of the specification or other document where it is explained (for idiots like me).

  • MCB2370U - LPC2378 - array size

    In case of collecting data from external 3-channel ADC via SPI, what is the maximum possible array size in the program ? I tried for single channel and it appeared to be 127. However, when using 3-channel, high-pass filter (Butherworth, 2-nd order) and 4-stage 2nd-order IIR filter, it was reduced to about 30 samples (reduced memory size). I need at least 1500 samples, is it possible to put such amount of samples into single array for one channel ? I don't use multiple shift registers, but single shift register, through which the array is passed. I attached picture presenting simpler example.
    Attachments:
    vi.png ‏7 KB

    Not a bug. This is correct behavior that is consistent with other parts of LabVIEW.
    The decision to handle multi-dimensional arrays like this was made long ago and is an enshrined part of the LabVIEW language spec. It will not be changed.

  • Get String array from Resultset

    In Tomcat 6.0.20 I am attempting to create an Oracle 9i resultset that outputs as a String array and need help creating the method.
    The CityData getCityList() method will be called in the CityServlet:
    CityServlet: String [] citys = cityData.getCityList();
    I started my below attempt but not sure how to handle the List/array part:
    CityData class: public ArrayList<String> getCityList() {     try {           .....           List<String> citys = new ArrayList<String>();           while(rs.next())           {               citys.add(rs.getString("city"));           }       }     return citys; }

    Hi!
    Try this:
    public City[] getCitys() throws Exception
        String sql = "SELECT * FROM citys ORDER BY name ASC";
        Vector v = new Vector();       
        ResultSet rs = null;
        java.sql.Statement stmt = null;
        try
            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            while( rs.next() )
                City city = new City(rs);
                v.add(city);
        catch (Exception e) { throw e; }
        finally
            try
                if (stmt != null) stmt.close();
            catch (Exception e) { throw e; }
        City[] citys = new City[v.size()];
        for (int i = 0; i < citys.length; i++)
            citys[i] = (City)v.get(i);
        return citys;       
    }Edited by: Bejglee on Mar 3, 2010 3:59 AM

  • Array Size doesn't work correctly after "Auto-indexed Tunnel"

    Array Size returns value even if Empty Array is detected after "Auto-indexed Tunnel" tha generates 2D array.
    See example + VI with correct output as I expected.
    OR
    There is problem with generating 2D array --- It's empty. 1D array is generated in right way. 100 x 0 but not Emptu Array.
    Attachments:
    ArraySize_Bug.vi ‏9 KB
    ArraySize_Corrected.vi ‏19 KB

    Not a bug. This is correct behavior that is consistent with other parts of LabVIEW.
    The decision to handle multi-dimensional arrays like this was made long ago and is an enshrined part of the LabVIEW language spec. It will not be changed.

  • Saving two dimensional array to a file

    I am trying to save a two dimensional array to a file.
    If I write a part of the whole array like Filename[1] it works fine.
    But the whole array will cause an Errormessage to appea:
    "cannot find symbol"
    Here is the Code:
      RandomAccessFile output = null;
        try
          output = new RandomAccessFile( "TestPlan.plan", "rw" );
          output.seek( output.length() );       // Dateizeiger an das Ende
          output.write( Karte );  // Zeile schreiben

    Seems that OutputStreamWriter and ByteArrayOutputStream can only handle one dimensional arrays, too.in that case, break down the arrays to single objects, and serialize them individually

Maybe you are looking for

  • New hard drive install on compaq cq56-115dx laptop

    the 250gb hard drive on my compaq presario cq56-115dx failed after 3 years.  i have installed a new hard drive and used the compaq recovery disks 1-4 to do a system install option.  everything ran fine during the installs of the disks and even prompt

  • Satellite P105 - DVD/CD ROM drive does not work

    The DVD/CD ROM drive on my P105 does not work at all.  I've tried the registry fix for the upper/lower limit thing - didn't fix the problem.  The drive does have power, does spin a disk, but it is not recognized by the system.  It doesn't show up in

  • Javascript coding issues (if else statements)

    Hello to all, I am posting for help for problems I am having with javascript. The website is www.goshowpro.com. Right now on the website it is connected by multiple html files but I would like to have it all on one single page with the animations res

  • How to read user - logon language (Urgent)

    Hi All, I have written the below code to display the language in english if it exists if not in french & so on, but i would like to know how i can read the language in which the user has logged on & use that as the first criteria. Eg: S_SPRAS = User

  • Problems to connect WLC after Firmware Update

    I have two WLC 4100, which just updated to the latest Software Version 3.2.193.5. Everything works fine, except I have problems connecting to the configuration Website. I have the following situation: My client is connected in VLAN A, there is also a