How many elements in an array?

Sounds like a simple question, right?
Apparently not.
LV 2010
I have a huge data structure, stored in DataLog files (thousands of them).
I want to convert this structure to Name/Value pairs ("Operator_Name", "Joe Smith"), for use in a TDMS file.
The structure is a cluster, with various clusters inside that, and inside those are DBLs, strings, BOOLs, other clusters, arrays, you name it.
My strategy is to obtain the CONTROLS[ ] property of the outermost cluster and call this VI.
The VI processes each control, decoding what type it is and handling it accordingly.
It works fine for STRINGs, NUMERICs, ENUMs, BOOLEANs, COMBOBOXes, TIMESTAMPS, and CLUSTERs.
For those simple ones, I use the LABEL.TEXT as the NAME and get the value (based on what type it is) as the VALUE.
For a CLUSTER, I get the CONTROLS[ ] array of the cluster and call myself recursively, to handle all the elements within the sub-cluster.
That all works fine.
But to handle an ARRAY, I'm stumped.
Attached is the code showing the case for an ARRAY.
What I'm doing is getting the CLASS NAME of the current control.
I LEGALIZE the label name (turn spaces into underscores, and maybe other special handling later).
For an ARRAY, I cast the generic CTL reference into an ARRAY reference, and get its VALUE.
I want to loop over each element of the array, and modify the name by the index number, and process each element.
There are arrays of STRINGS, arrays of DBLs, arrays of CLUSTERs - all types.
The question is - how many array elements are there?
The constant "10" in this diagram is a dummy - just there to see if it works.
it does work, except that I get 10 sets of answers, whether the real array has 2 or 20 elements.
I thought the array's VALUE would be an ARRAY of VARIANTs, but no - it's a single VARIANT.
I can't use VARIANT to DATA on the array's VALUE - I don't know what TYPE the array is.
I thought maybe the ARRELEM refnum would be NIL if I was past the end, but that's not the case - there's only one refnum for any array element, whether it exists or not.
If I check for errors, it complains that I cannot set the INDEXVALS property of a strict typedef array, even though it works just fine.
If there was a method to SELECT ALL on the array, I could use the SELECTION SIZE to figure out how many elements there are, but I see no such method.
The NUMBER OF ROWS / COLUMNS refers to the number of VISIBLE rows/columns, and has nothing to do with how much data is present.
So... How do I find out how many elements are in the array?
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

The ArrElem reference property is not a reference to any particular element of the array. 
On the contrary, it is a reference to the element addressed by the current ARRAY INDEX(es).
That's why my code above can read out the values for element 0, element 1, etc.  I've verified that this works.
There is only one set of PROPERTIES for the array elements; if you use the ArrElem refnum to set a background color of blue, then ALL elements turn blue, but you can obtain the VALUE of a given element by setting the ARRAY INDEX(es) and accessing via the ArrElem.
I was thinking that maybe LabVIEW did a trick by setting this to NIL to indicate "no such element", but that's not the case.
In any case, the question remains: How do I determine how many elements there are?
The VALUE of the array is a variant: just what is in that package?
As I said, I don't see how to use VARIANT TO DATA; I don't know what kind of data it is.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

Similar Messages

  • SLD Export, how many elements?

    I'm doing an incremental export from an SLD on a 6.40 system.
    The status is "Exporting: Performing incremental export: xxxxxxxx"
    It's been running for about 6 hours, and is up to 700k+ elements.
    How can i see how many elements there are in total or left to go?
    I though it would be possible to add the objects from within in the "data" section in the details header.
    But adding the objects for sld/active and sld/restored namespace has already been passed a few hundred k's ago.
    You do not need to post any notes refering to how the SLD works etc, since I've been looking into this and the help and this information cannot be found in the "normal" SLD documentation.
    Best regards
    Tomas

    Hello Federica,
    how did you manage to use oracle.sql.ARRAY[]?
    When i try to create a deployment for a method using this as parameter, i get the error:
    "Parameter #1 is of type oracle.sql.ARRAY, which does not map to any PL/SQL data type".
    Thank you for your help!
    Udo

  • How many elements can ...

    How many elements can I map in a plsql table of varchar2 from java?
    I have an plsql variable like "create or replace type CHAR_ARRAY as table of varchar2(255)", which i mapped using an oracle.sql.ARRAY[] variable in java because it is an IN/OUT var.
    In java class I reload the array, but I can load only 17 elements, after I have this error:
    ERROR:
    ORA-01041: internal error. hostdef extension doesn't exist
    and then the connection closes.
    Can someone help me?

    Hello Federica,
    how did you manage to use oracle.sql.ARRAY[]?
    When i try to create a deployment for a method using this as parameter, i get the error:
    "Parameter #1 is of type oracle.sql.ARRAY, which does not map to any PL/SQL data type".
    Thank you for your help!
    Udo

  • I linux inode which contains 13 member array wich stores the actual block address of data .Similarly in windows how data is managed in disk ?. How many members in this array ?

    I linux inode which contains 13 member array wich stores the actual block address of data .Similarly in windows how data is managed in disk ?. How many members in this array ?

    Hello Vijay Nerkar,
    Your question is not related to Windows Forms General. What is the data you mean and also what is that array?
    If you are looking for something related to Windows File System, see some words here:
    http://en.wikipedia.org/wiki/File_system
    For example
    "Windows makes use of the
    FAT, NTFS,
    exFAT and ReFS file systems (the last of these is only supported and usable in
    Windows Server 2012; Windows cannot boot from it).
    Windows uses a drive letter abstraction at the user level to distinguish one disk or partition from another. For example, the
    path <tt>C:\WINDOWS</tt> represents a directory <tt>WINDOWS</tt> on the partition represented by the letter C. Drive C: is most commonly used for the primary hard disk partition, on which Windows is usually installed and from which it boots. This "tradition"
    has become so firmly ingrained that bugs exist in many applications which make assumptions that the drive that the operating system is installed on is C. The use of drive letters, and the tradition of using "C" as the drive letter for the primary hard disk
    partition, can be traced to
    MS-DOS, where the letters A and B were reserved for up to two floppy disk drives. This in turn derived from
    CP/M in the 1970s, and ultimately from IBM's
    CP/CMS of 1967.
    For more details, consider consult on MS Answers:
    http://answers.microsoft.com/en-us/windows
    Regards,
    Barry Wang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How many elements can I insert into a form?

    When creating my form I received a notice that I had reached the maximum number of elements for my form!  I was near the end stages of my design, Ouch! 
    What can I do?  Is it possible to cut and past sections of my form to create a new form(s) and link it all together?

    I am limited to the amount of check box elements I can insert into a form by Adobe Forms Central.
    I would like to insert another 200-250 more check box elements to complete my form. 
    Will upgrading to the next package (Unlimited Forms) help me in completing this task or should I look for another solution? 
    Any help and suggestions would be greatly appreciated.
    lpqn wrote:
    When creating my form I received a notice that I had reached the maximum number of elements for my form!  I was near the end stages of my design, Ouch! 
    What can I do?  Is it possible to cut and past sections of my form to create a new form(s) and link it all together?

  • How to average each element in an array

    I have data from a Gage Card that I would like to average.  I am tuning a laser over a 50 mA range and for each 1mA increment in current, I am taking 100 scans.  Each scan consisting of about 200 points.  I cannot average more than 10 shots using the Gagecard so I would like to capture 100 scans, and average them to reduce noise.  Currently, I have my capture vi inside of a for loop which repeats 100 times and each scan writes to a file, but I would like ony 1 scan (the lower noise averaged one) per current increment.  
    How can I average each element of 100 arrays and output this to an array?
    Thanks for the help 

    It sounds like you want to average element 0 across 100 arrays and make that element 0 of the new averaged array.  Then average element 1 across 100 arrays and make that element 1 of the new array ...   ?????
    How are you working with your 100 1-D arrays now? 
    What you should do is make a 2-D array where one dimension is 100 (for the number of individual arrays) and the other dimension is how many elements are in those 100 1-D arrays.  Then you can use for loops with auto indexing to break the 2-D array down into each row or column, do the average of that array, and autoindex on the other side to build back up into the new 1-D array of averages.  You may need to to a transpose array going into your for loop in case the arrays are indexed in the wrong direction.
    Message Edited by Ravens Fan on 01-21-2008 04:26 PM
    Attachments:
    Example_BD.png ‏6 KB

  • Number of elements in an array

    Hi,
    I have been trying looking for a simple function to get number of elements is an array. Have gone though older posts but could not find answer to it.
    The function should work for following examples:
    char* name = "nInstruments"
    float state[] = {1.0, 2.0}
    I tried sizeof but it returns size of "type" in bytes. For example in example 2, it will just return 4.
    Does someone know a way to do it?
    Ciao
    RB
    Solved!
    Go to Solution.

    RB,
    In C, if an array is declared on the heap, as opposed to on the stack as in your example above, the sizeof operator only returns the length of the pointer that holds the array which, in a 32-bit program, is always 4 bytes. This is because the compiler has no way of knowing how many elements that array actually holds. The length of a C array is a fairly fluid concept. The real size of the array is usually determined by some memory manager somewhere (usually, malloc), but it's not something that the language itself has anything to say about.
    When you declare the entire array as a local variable, however, the compiler must create room for the full array on the stack, and therefore it is able to return the true size of the array via the sizeof operator. (The same is true if it's a global variable, even if it's not on the stack, in that case)
    For this reason, using the sizeof(array) / sizeof(array[0]) trick is iffy. It might work, or it might not work, depending on how the array is declared.
    For this reason, most C APIs that accept or return arrays, will usually also have some method of communicating the length of the array, usually as an additional parameter of some function. Because .NET APIs usually have no need to do this, the C wrapper for a .NET API in CVI does this for you when it handles .NET arrays. For example, here's what a function signature might look like:
    int CVIFUNC Namespace1_Class1_Test1DArrays (Namespace1_Class1 __instance, int * inA, int __inALength, char *** outA, int * __outALength, Namespace1_Class2 ** refA, int * __refALength, double ** __returnValue, int * ____returnValueLength, CDotNetHandle * __exception);
    Luis

  • How do I extract the length of an element in an Array List

    Hello there,
    I am facing this problem with an Array List of elements. I am trying to extract the individual length of a particular element in the array list . Now if I know the element is a String is this valid?
    int lengthOfElement = 0;
    lengthOfElement = ((String)parms.get(i)).length();
    Your answer is much appreciated
    Regards

    Snap!I don't know how many times I've seen people post
    saying that they have a list where each element is a
    String, but they keep on getting ClassCastException :)Damn those Integers!
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How Do I Print the Number of Elements in An Array

    How do I print: "There are ____ number of elements in the array?"

    If you have a String holding a sentence, and if you split on non-empty sequences of whitespace (if the string has newlines in it, you'd probably need to pass the argument that makes \s match newlines, and for that you would probably need to use java.util.regex.Pattern -- see the docs and try some tests), when you'd get an array of Strings that were the non-whitespace parts of the original String. That makes for a reasonably good definition of the words in the sentence, although you could arguably get into some gray areas (does "isn't" count as one or two words? Does a sequence of numbers or punctuation qualify as a word?). In that case, counting the number of elements in the resulting array of String. using .length, would be a reasonable way to get the number of words in that sentence, yes.
    But rather than asking for confirmation on forums, why don't run some tests?
    import java.io.*;
    public class TestWordCount {
      public static void main(String[] argv) {
        try {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          String line;
          while((line = in.readLine()) != null) {
            int count = // your code here, to count the words
            System.out.println("I see " + count + " words.");
        } catch (IOException e) {
          e.printStackTrace();
    }Put your word-counting code in there, then run it from the command line. Type in a sentence. See how many words it thinks it found. Does it match with your expectation, or the examples given (hopefully) with your homework assignment?

  • Count how many time we have each element

    I can't count how many the same element is on my array, I have an array [21, 12, 4, 21, 21, 4]
    I expect to have something like this:
    number exist number
    21 3
    12 1
    4 1
    below is the code
    System.out.printf("%10s,%10s \n", "number exist", "number");
              for(i = 0; i < list.size(); i++){
                   for(int j = 0; j < list.size(); j++){
                        if (list.get(i) == list.get(j))
                             v++;
              System.out.printf("%10s,%10s \n",v,list.get(i));     
    Edited by: ronisto on 11-Mar-2008 1:34 PM
    Edited by: ronisto on 11-Mar-2008 1:39 PM

    good actually I 'm using a List, I could'nt find where is wrong, I can print for the first one, but if I try to use the for it' s not working...look the code below with a list like this [5 , 1, 7, 1, 1, 5]
              System.out.printf("%10s,%10s \n", "Column1", "Column2");
                   for(j = 0; j < list.size(); j++){
                             if (list.get(j) == list.get(0))
                                  v++;
                   System.out.printf("%10s,%10s \n",v,list.get(0));
    result give me:
    Column1 Column1
    3 1
    til here is good but when I try to print samething for all elements of my list it doesn't work
    System.out.printf("%10s,%10s \n", "number exist", "number");
                   for (i = 0; i < list.size(); i++){
                        for(j = 0; j < list.size(); j++){
                             if (list.get(j) == list.get(i))
                                  v++;
                   System.out.printf("%10s,%10s \n",v,list.get(i));
    Edited by: ronisto on 11-Mar-2008 6:04 PM

  • Is how can I calculate how many transition​s are inside an array?

    Let’s assume that we have an array of 582 elements. Some of them are above 4 and some of them are below 1,let’s also say that values who are above 4 are equal to True (1) and the values below 1 are equal to False (0). The question is how can I calculate how many transitions are inside the array from 1 to 0?How many peaks I have? Can please someone suggest a code solution for that?
    Solved!
    Go to Solution.

    If you only care about actual transitions and not the type of them, I'm a fan of the simple XOR.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Count Transitions.png ‏19 KB

  • How many computers can I install Photoshop Elements 12 on?

    How many computers can I install Photoshop Elements 12 on?

    No, if you mean can you copy the installed version over. That never works because PSE is a highly complex program that strews stuff all over your hard drive and you can never hope to find all the bits and bobs. You should deactivate it on the computer you no  longer need, then install from scratch on the new machine.

  • On how many computer can I install Premiere Elements (one licens)

    On how many computer can I install Premiere Elements (one licens)

    number
    What are the computer operating systems involved? Are you installing from installation files (from online download purchase) or from installation disc
    (from purchase in boxed packaging)? Answers to those questions would probably get you the best possible answer to your question.
    If installation files.....
    You are not going to be able to install a Premiere Elements Windows purchased serial number on a Mac computer or a Premiere Elements Mac
    purchased serial number on a Windows computer.
    If installation discs...
    Box packaging typically comes with two installation discs....one for Windows and one for Mac. In this type of situation, typically you use one
    serial number for them both. If that is the case, then the following applies...
    Adobe allows you to use the same purchased activated serial number on no more than 2 of your computers. And, you do not use them at the same time.
    If you are dealing with two computers with the same operating system, then you should be able to use that same purchased serial number for that operating system on no more than 2 of your computers. Again, you do not use them at the same time.
    Please let us know if any questions or need clarification.
    Thanks.
    ATR

  • How many times can I install Photoshop and Premiere Elements 13?

    How many times can I install Photoshop and Premiere Elements 13?

    mbuenger
    Are you referring to how many times can I install, uninstall, reinstall Photoshop Elements 13 or Premiere Elements 13 on the same computer?
    Or, how many of your computers can have a same purchased activated serial number at the same time for either of these products?
    If the former, I know of no limit.
    If the latter, the answer would be as John as mentioned.
    ATR

  • How many times can I download photoshop elements?

    I recently purchased Photoshop elements 13 and installed it on my home computer but I realize that I also need it on my office computer.  How many downloads can I do with my purchase?  I went to my profile and it says that downloads are not available.

    In general there is no limit to the number of times you can download.  The number of activated installations you can have at any given time is limited to two.
    PSE 10, 11, 12,13 - http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-10-11-downloads.html

Maybe you are looking for

  • Display Month number

    Hi, In our report, we have a requirement to display the month numbers. For example, if the user selects Jan for the time dimension prompt, it should display 1 Month Ended. If selection September, it should display 9 Months Ended. Is there any way to

  • Outlook Connector troubleshooting

    I'm having some trouble with the Connector for Microsoft Outlook 7.0. Whenever I try to access the company Address Book, I get this error: [Error  ]: XLdap::getEntriesCount xldap_search_ext_s failed 0x32 [Error  ]: XLdap::getEntriesCount ldap error :

  • Error msg. Changing Modules

    I just downloaded Lightroom 2.6 and when it opens I get "an error occurred when attempting to change modules".  I'm running LR on a MacBook Pro running OS 10.6 I tried shutting down and restarting but to no avail. Any suggestions? Thanks.

  • Macbook Pro 1st gen Unibody Firewire 800 problem

    Recently I notice when I hook up a hard drive to my firewire 800 port and daisy chain another drive my mac pops up an error stating that the drives were ejected incorrectly.  I wasn't trying to eject a drive just daisy chain an additional drive.  Is

  • Custom Product catalog item text not displayed after product search

    Hello Experts, 1. We have configured a custom PCAT_ITM text - Product catalog item text. - (say 000A ) 2. Have appropriate text determination procedure, access sequence to determine this custom text 3. The text determination procedure has been chosen