Coordinates of array elements

Hi,
I'm playing around with mouse click coordinates, mostly because its Friday afternoon but also because it might be useful
In the attached code I wish to click on one of the strings of my array control and find out which element in the array it corresponds to. (This will later be used to fire up other bits of code depending on the array content)
I can use the position of the array and the coordinates of the mouse and it all works fine.
BUT... only if I select the zeroth element before I run the code. If I select any other element then run the code I get erroneous results.
So - is there a way to acquire the coordinates of the zeroth element of my array regardless of what the user has just done?
I can think of workarounds using the coordinates of the array control (instead of the string coordinates) but this is affected by the control label size/visibility so feels less reliable.
Using version 8.5.
Thanks,
Ian
Solved!
Go to Solution.
Attachments:
click on array.vi ‏23 KB

There is a utility VI from the LAVA repository located here.
That deals with this problem:
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!

Similar Messages

  • How do I programmat​ically modify array element sizes?

    Hi All,
    I have a quick question about modifying the size of array elements. Hopefully someone can help, because I am at a dead end!
    I am logging some intensities from a Fibre Array using a camera. For calibration of the system, I acquire an image from the camera, click points on the image to divide it into areas of interest. I overlay my image with a grid showing the regions of interst - for example a 4x6 array. I then have to select the fibres - or ROIs - I want to log from.
    I have a cluster type-def ( a number and a boolean) to specify the fibre number and to turn logging from that fibre on/off. I overlay an (transparent) array of this typedef over my image to correspond with the regions of interest. So here's my problem - I want to modify the dimensions of the array so each control matches my ROI. I can resize the elements by rightclicking on the elements on the frontpanel, but can't find a way to do it programmatically. The Array Property Node>>Array Element>>Bounds won't 'change to write'...thats the first thing I tried.
    Its really only important that the elements align with my ROIs - so programmatically adding in gaps/spacings would also work for me...but again I can't figure out how to do this! I've attached a screenshot of part of my image with array overlaid to show you all exactly what my problem is.
    Thanks in advance for you help,
    Dave
    PS I am running Labview 8.6 without the vision add on.
    Solved!
    Go to Solution.
    Attachments:
    Array_Overlay.png ‏419 KB

    Here's my cheat (and cheap?) way If you want to get fancy and center the numeric and boolean indicators, you could add spacers on the north and west sides, too.
    Attachments:
    ClusterSpacer.vi ‏13 KB

  • How can I display all results of a array element in a TS2.0 NumericArrayMeasurement in a single report line?

    TestStand2.0 generates for each result property ( data, limits, status...) of each array element in a NumericArrayTest an extra line in the test report.
    How can I change this to display all result properties of one array element in a single line?
    How can I reduce the spaces between the property name and its value in the report?
    How can I delete the message: "Measurement[x]" and display only the Measurement Alias (named in the Edit Limits menu)?
    This means I like to change my report from:
    Measurement[0] (ADC1):
    Data: 5000
    Status: Passed
    Measurement[1] (AD
    C2):
    To:
    ADC1: Data: 5000 Status: Passed
    ADC2: ...

    Hi,
    What you can do, is use the Override Callbacks for Modify the Report that is Generated.
    Also you can also change the report sequence 'reportgen_txt.seq' to achieve the desired affect. If you go for modifying the report sequence then copy this to the User folder and then make your changes.
    In the Resources Library you can find simple examples were the report has been modified by either using the Override Callbacks or by modifying the actual sequence.
    One other item in the Report Options you will have to set the 'Select a Report Generator for Producing the Report Body' control to use the Sequence instead of the DLL.
    Hope this helps
    Ray Farmer
    Regards
    Ray Farmer

  • How to use XSLT for mapping feild names one by one to array element

    I have a XSLT case to map all the attributes feild name(not value) which has no child to the target, which is array loop.
    I give an sample below.
    source:
    <Items xmlns="http://www.example.org/sample">
    <SourceSystem>SourceSystem2573</SourceSystem>
    <TimeStamp>2010-01-17T20:54:08.234</TimeStamp>
    <Item>
    <ID>2574</ID>
    <Type>2575</Type>
    <Name>2576</Name>
    </Item>
    </Items>
    source XSD like:
         <element name="Items" type="tns:ItemsType"></element>
         <complexType name="ItemsType">
              <sequence>
                   <element name="SourceSystem" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="TimeStamp" type="dateTime" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Item" type="tns:ItemType"
                        maxOccurs="unbounded" minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    <complexType name="ItemType">
              <sequence>
                   <element name="ID" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Type" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    <element name="Name" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    target need to be like:
    <ns1:AttributesCollection>
    <ns1:Attributes>
    <ns1:fieldname>SourceSystem</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>TimeStamp</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>ID</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Type</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Name</ns1:fieldname>
    </ns1:Attributes>
    </ns1:AttributesCollection>
    target XSD:
    <xs:element name="AttributesCollection" type="AttributesCollection"/>
    <xs:complexType name="AttributesCollection">
    <xs:sequence>
    <xs:element name="Attributes" type="Attributes" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Attributes">
    <xs:sequence>
    <xs:element name="fieldname" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    I know we can use local-name() to get the tag/field name,
    but I have not idea how to get these leaf field names one by one and then mapping to every array elements.
    I tried whole day but no successful
    Does anyone have some idea?
    Thanks very much!
    Keith
    Edited by: user1065212 on 17-Jan-2010 22:50
    Edited by: user1065212 on 17-Jan-2010 22:53
    Edited by: user1065212 on 17-Jan-2010 22:59

    can you paste source xsd and the correct xml output, the current one isn't really valid
    <ID>2574</TotalNumOfItems>

  • Allocate array elements one at a time?

    Is there a way to allocate array elements one at a time?
    The following code will crash because the minimumLogIndices array is not allocated.
    // get all indices where cArray[i] > minimumLog
    int[] minimumLogIndices = null;
    for (int i=0; i < columns; i++)
      if ((cArray[i] > minimumLog))
        minimumLogIndices[i] = i;
    }I would like a statement like:
    minimumLogIndices[i] = new(i);but this is not allowed, of course.
    If I use ArrayList, then the elements can be added one at a time, but I cannot use int.
    null

    int[] minimumLogIndices = new int[columns];As described here:
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
    [Edit] The array will, however, have "holes" in it when cArray[i] <= minimumLog, but that's inevitable if you are using an array.

  • How to set the value of an array element (not the complete array) by using a reference?

    My situation is that I have an array of clusters on the front panel. Each element is used for a particular test setup, so if the array size is three, it means we have three identical test setups that can be used. The cluster contains two string controls and a button: 'device ID' string, 'start' button and 'status' string.
    In order to keep the diagrams simple, I would like to use a reference to the array as input into a subvi. This subvi will then modify a particular element in the array (i.e. set the 'status' string).
    The first problem I encounter is that I can not select an array element to write to by using the reference. I have tried setting the 'Selection s
    tart[]' and 'Selection size[]' properties and then querying the 'Array element' to get the proper element.
    If I do this, the VI always seems to write to the element which the user has selected (i.e. the element that contains the cursor) instead of the one I am trying to select. I also have not found any other possible use for the 'Selection' properties, so I wonder if I am doing something wrong.
    Of course I can use the 'value' property to get all elements, and then use the replace array element with an index value, but this defeats the purpose of leaving all other elements untouched.
    I had hoped to use this method specifically to avoid overwriting other array elements (such as happens with the replace array element) because the user might be modifying the second array element while I want to modify the first.
    My current solution is to split the array into two arrays: one control and one indicator (I guess that's really how it should be done ;-) but I'd still like to know ho
    w to change a single element in an array without affecting the others by using a reference in case I can use it elsewhere.

    > My situation is that I have an array of clusters on the front panel.
    > Each element is used for a particular test setup, so if the array size
    > is three, it means we have three identical test setups that can be
    > used. The cluster contains two string controls and a button: 'device
    > ID' string, 'start' button and 'status' string.
    >
    > In order to keep the diagrams simple, I would like to use a reference
    > to the array as input into a subvi. This subvi will then modify a
    > particular element in the array (i.e. set the 'status' string).
    >
    It isn't possible to get a reference to a particular element within an
    array. There is only one reference to the one control that represents
    all elements in the array.
    While it may seem better to use references to update
    an element within
    an array, it shouldn't really be necessary, and it can also lead to
    race conditions. If you write to an element that has the
    possibility of the user changing, whether you write with a local, a
    reference, or any other means, there is a race condition between the
    diagram and the user. LV will help with this to a certain extent,
    especially for controls that take awhile to edit like ones that use
    the keyboard. In these cases, if the user has already started entering
    text, it will not be overwritten by the new value unless the key focus
    is taken away from the control first. It is similar when moving a slider
    or other value changes using the mouse. LV will write to the other values,
    but will not rip the slider out of the user's hand.
    To completely avoid race conditions, you can split the array into user
    fields and indicators that are located underneath them. Or, if some
    controls act as both, you can do like Excel. You don't directly type
    into the cell. You choose w
    hich cell to edit, but you modify another
    location. When the edit is completed, it is incorporated into the
    display so that it is never lost.
    Greg McKaskle

  • Problem in assigning value to an array element

    hi all
    in the following prog i am not able to assign the value to the array element
    i am not getting why it is giving me error
    //my program is as follows
    public class ArrayTest
         static int [] intArray = new int[5];
         static int [] intArray1 = new int[1];
         intArray1[0] = 5; // this line gives error
         static char [] charArray = new char[5];
         public static void main(String args[])
              System.out.println(charArray);
              intArray1 = intArray;
    }thanx in advance as usual

    The problem is that you try to execute code outside a method. This can be only done in form of a variable declaration or as a static initilization block which will be executed once when the class is loaded:public class ArrayTest
         static int [] intArray = new int[5];
         static int [] intArray1 = new int[1];
         static char [] charArray = new char[5];
         static {
              intArray[0] = 5;
         public static void main(String args[])
              System.out.println(charArray);
              intArray1 = intArray;
    }

  • How to change the color of Numeric array elements (seperatel​y) programmat​ically using property node??

    For example, i have 3 numeric controls, controlling 3 numeric array elements (Numeric control is connected directly to indicator). Then if i change value in numeric control 1, then the array element No.1 of numeric array should turn red when value exceeds 5. Similarly when i change num control 2 then element 2 of array should turns red when value in num control 1 exceeds 10. Similarly for 3rd element. In other words, i want to control the property of array elements individually through seperate numeric control.
    I have done it for single numeric indicator.i.e. when i change numeric control's values then a single numeric indicator changes values and color (Numeric text BG property) but with array, the color of whole array changes but i want to change color of singles element of array.
    Please help thanks.  
    Solved!
    Go to Solution.

    ...or replace the numerics with clusters that have a numeric and a color box. make the background of the nmeric transparent and slide the color box behind the numeric. Use the color box to control the background color.
    Other alternatives would use a cluster instead of the array or if your req's are really weird "roll-your-own" with a Picture control.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to set an array element in an object type of array??

    Hi,
    I have set attribute as follow:
    Color[] colors;
    Color[] colors = new Color[20];
    colors[0] = "Red";
    colors[1] = "blue";I can't compile this code. It said:
    "Incompatible type -found java.lang.String but expected Colors
    Could you tell me how to set an array elements when the array type is an object?

    in your case, the array shouldn't be Color[] but String[] since you re intending to put strings into it
    by the way, you could also use a hashmap to map a string to a color:
    HashMap<String, Color> hm = new HashMap<String, Color>();
    hm.put("Red", Color.RED);
    hm.put("Blue", Color.BLUE);
    etc.

  • "In initializer for 'mxmlContent', type Object is not assignable to target Array element type..."

    Hi all,
    So I've have built an application on flash builder 4.5 using Christophe Coenraets' tutorial "Building an EmployeeDirectory" (http://www.adobe.com/devnet/flex/articles/employee-directory-android-flex.html#articlecont entAdobe_numberedheader).
    I'm getting this error message "In initializer for 'mxmlContent', type Object is not assignable to target Array element type mx.core.IVisualElement." and then the debugger highlights my code this line of my code "</s:List>" in my EmployeeDetails.mxml file. This started after I coded Part 5, Step 2 "Integrating with the Device Capabilities: Triggering the Actions".   The rest of the code debugged fine.
    I think it relates to Christophe's note "Note: Make sure you import spark.events.IndexChangeEvent (and not mx.events.IndexChangedEvent) for this code to compile.".  I don't know where to place this
    " import spark.events.IndexChangeEvent;" line of code. 
    Any help?  Tks in advance..
    Any help would be greatly appreciated.  Thanks

    You have a DataGrid directly inside a State element. Perhaps wrap it in an AddChild element?
    More information on using states can be found here:
    http://livedocs.adobe.com/flex/3/html/help.html?content=using_states_1.html

  • Read part of an array element

    Hello All.
    As indicated in the title, I am trying to read part of an array element.
    What I'm doing is reading values from a LeCroy scope using a "write" than "read" I have returned the read values into an array but the issue is the scope returns a value "1, 52.33E-3"
    I simply want the element to be 52.33 that way I can use that for other calculations.
    For example my array is.
    "1, 34.334E-3"
    "1, 53.343E-3"
    "1, 143.232E-"
    And I want it to be
    34.334
    53.343
    143.232
    Thanks!
    Solved!
    Go to Solution.

    Another option is to use Spreadsheet String to Array and use the comma as the delimiter.  It can actually change your string into an array of numbers.  Then you just index out the number you want.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • Display a particular array element on the front panel

    Hello,
    I was wondering if it's possible to change which element of an array control is displayed on the front panel from within the program.
    Here's why I want to do it: I have an array of clusters, each of which contains a set of controls.  The controls in each cluster specify a bunch of different parameters for a few different instruments that are being controlled by Labview.  The user changes all the values on the front panel before the program starts, then the program steps through the array elements one by one.  I'd like to be able to change the array's display so that the user can know which set of parameters is active (and thus what is currently in force) while the program is going -- otherwise the element that is displayed is just wherever the user left it last.
    Thanks in advance for any help.

    See also: http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=317419#M317419
    LabVIEW Champion . Do more with less code and in less time .

  • Best way to iniitialize a queue with array elements

    Hi Guys
    I'm looking for a bit of performance optimization..  
    I'm developing a noise measurement application using LV8.6 and Win Xp /Win 7.
    To put it very simple I have a loop that samples, and a loop that does the math. data is shipped in a queue, producer / consumer style.
    So far so good.. Question is - is there a specific and more optimized way to declare this queue?
    I was wondering if declaring the queue with an initialized array element of a fixed size (the number of samples pr. read from the sound card will be known at runtime) would produce a queue that would be less heavy on dynamic allocation of memory compared to a queue obtained using a simple control no values.
    I've attached a screen dump to maybe make the question more obvious..
    I've been thru the "clear as mud" thread, as recommended in other threads that covers this topic - but i gets very high tech, and I kind of lost my way in it.. So looking for a more simple "you should use solution #x, because..."
    Thank you in advance. 
    Solved!
    Go to Solution.

    I believe (but am not sure) RT FIFOs will allocate this memory for you ahead of time. But, remember they are not deterministic on windows. You need to wire an array constant of the correct size into the FIFO read function also to avoid memory allocation, which is easy to overlook. It's worth looking into, if nothing else, assuming you have RT functions available. WIth this method, the queue size needs to be set, and you run the risk of overflowing and losing elements if not handled correctly. 
    Just throwing other options out there.
    CLA, LabVIEW Versions 2010-2013

  • How to copy an array element in one class to an array in another class?

    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?

    drew22299 wrote:
    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?System.arrayCopy will overwrite whatever is already in the array. It is your job to make sure it copies into the proper array location.
    That being said, you're only moving a single student. This is not something you would use arrayCopy for, as you can just do that with simple assignment. Also, you should consider giving Class a method to add a student to its student list, as the class should know how many students it has and can easily "append" to the array.
    Note: I hope you noticed the quotes around append. Java's arrays are fixed size. Once allocated, their size cannot change. You may want to consider using one of the List implementations (ArrayList, for example) instead.

Maybe you are looking for

  • How do I create a TASK ICON ???

    Hi, I would like to put my application in the WINDOWS TASK BAR. Those nice little icons that appear beside the clock. I believe this solution will kill the portability of my code, but I am willing to pay that price. Thanks, Sergio

  • I just upgraded to Lion and can't find my EXS24 sampler instruments

    The instruments that came with Logic are still in their place, but can't find user sampler instruments.  It used to be (user / library / application support / logic / sampler instruments, but there is no "library" folder in the user folder anymore. 

  • What's with the "Sufficient permissions" warning?

    Occasionally, in CS5, when I go to move a file from one folder to another in Bridge I get a message that I can't do it because I do not have sufficient permissions.  Why is Adobe scolding me in this way?  Who do I go to to these mysterious permission

  • Display messages dynamically

    i want to show messages dynamically  i.e text and item no combindly please help me out. murali

  • Bug? Two Doubles not detected as equal v8.6

    Try this: -  Create a while loop -  Wire in a double, 0. -  Make this value a shift register -  Inside the while loop, continously add .1 -  Also, wire the shifted value to a "Equals?" comparison -  Wire this to stop the while loop when the shift reg