Pick up specific indices from for loop

hi guys , 
i have a for loop with N = 60 , i'm trying to make something when the index (i) reachs specific number , the indecies i'm interested in are
1 ,5 , 9,13, 17, 22, 26, ,30,34,38,43,47,51,55,59
the difference is 4 in some of them but it changes to 5 @ 22 and 43 and come back to 4 in between .
can anybody help me pick up these indecies ?
Solved!
Go to Solution.

Why would you need a mathematical formula?
What is a "boolean variable"? In the context of LabVIEW, you need to explain in more detains what you mean )
I would just do something similar to the following (The second loop will iterate 60 times):
Note that the parts on the left will be folded into a single boolean array constant at compile time, so there is no overhead during execution.
(You can also do it all in a single loop. try it. )
LabVIEW Champion . Do more with less code and in less time .
Attachments:
IrregularSelection.png ‏16 KB

Similar Messages

  • Update a front panel indicator from a loop inside a called vi. Without exiting

    I am looking for the best way to update some indicators from within loop within a called .vi.
    I need to update the front panle without exiting the loop.
    I am able to use functional global vi to update the values of front panel indicators from within my nested loops, but I am looking for the best way that these values can be read to update my indicators.
    Thanks

    Or a cluster of references, that way each reference can be named, and can be different types to match the respective indicator.
    There are also methods where you can just send in a VI reference, and in the subVI traverse all the controls and search for the appropriate references by name.
    Take a look at this long nugget.

  • Display text in label from 'for loop'

    Hi
    I'm new to Java, in fact so new just started yesterday.
    I'm trying to display all the values from a for loop into a label control in my application.
    Problem is, its only displaying the last number. Can anyone please help.
    Thanks
    George
    --------------------------------------------Code----------------------------------------------
    int lottoNumbers1 = Integer.parseInt(txtLotteryNumbers1.getText());
            int lottoNumbers2 = Integer.parseInt(txtLotteryNumbers2.getText());
            int lottoNumbers3 = Integer.parseInt(txtLotteryNumbers3.getText());
            int lottoNumbers4 = Integer.parseInt(txtLotteryNumbers4.getText());
            int lottoNumbers5 = Integer.parseInt(txtLotteryNumbers5.getText());
            //int lottoNumbers6 = Integer.parseInt(txtLotteryNumbers6.getText());
            int arrUserInput[] = {lottoNumbers1, lottoNumbers2, lottoNumbers3, lottoNumbers4, lottoNumbers5};
            int arrRnd[] = new int[5];
            Random rnd = new Random();
            for (int i = 0; i < arrRnd.length; i++) {
                arrRnd[i] = rnd.nextInt(49);
            boolean isfound = false;
            for (int i = 0; i < arrUserInput.length; i++) {
                isfound = false;
                for (int j = 0; j < arrRnd.length; j++) {
                    if (arrUserInput[i] == arrRnd[j]) {
                        isfound = true;
                if (isfound) {
                    //System.out.println("Same Numbers again : " +arrUserInput[i]);
                    String numbers = Integer.toString(arrUserInput[i]);
                    int res = NumberCount.wordcount(numbers);
                    //System.out.println("Number of matches : " +res);
                    switch (res) {
                        case 1:
                            lblNumbersEntered.setText("You matched 1 number " + arrUserInput[i] + " and win nothing");
                            System.out.println("Number of matches : " +res);
                            break;
                        case 2:
                            lblNumbersEntered.setText("You matched 2 number " + arrUserInput[i] + " and win £2");
                            System.out.println("Number of matches : " +res);
                            break;
                        case 3:
                            lblNumbersEntered.setText("You matched 3 number " + arrUserInput[i] + " and win £10");
                            System.out.println("Number of matches : " +res);
                            break;
                        case 4:
                            lblNumbersEntered.setText("You matched 4 number " + arrUserInput[i] + " and win £50");
                            System.out.println("Number of matches : " +res);
                            break;
                        case 5:
                            lblNumbersEntered.setText("You matched 5 number " + arrUserInput[i] + " and £1000");
                            System.out.println("Number of matches : " +res);
                            break;
                        default:
                            lblNumbersEntered.setText("You have matched no numbers");
                            System.out.println("Number of matches : " +res);
                            break;

    If you want a complete history of each time you go through the loop, you have to construct the history:
    [code]
    myLabel.setText("This");
    MyLabel.setText(" is");
    myLabel.setText(" good");
    [/code]
    myLabel will contain only " good", since that is what myLabel was set to last, but if you want the history:
    [code]
    myLabel.setText("This");
    MyLabel.setText(myLabel.getText() + " is");
    myLabel.setText(myLabel.getText() + " good");
    [code]
    Should give you "This is good", as each time the contents of myLabel are retrieved and appended before myLabel is given the new set value.

  • Graph from For Loop

    hello,
    I have a problem with one of my applications I am developing.
    I calculate a timeSeries and I need to graph it on linechart. The timeSeries is calculated through an iteration of For Loop
    I have tried to write in an array, but it didn't work since I can only take one value.
    I tried to write the value in a datagrid but that didn't work either!
    not because it is impossible, but because I am an idiot
    http://alimsyed.com

    Hi Dimitris,
    Thanks for the post and I hope your well today.
    You can achieve this by using a reference of the graph from the main VI, pass it to the subVI vi and use a property node to update the graphs value. 
    I have attached an edit of your code to show this, labVIEW 8.6. 
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!
    Attachments:
    mainVI.vi ‏9 KB
    subVI.vi ‏13 KB

  • Is it possible possible to exist from FOR loop while executing

    Hi
    Like break in C, is it any method available in LabVIEW to exist from a FOR LOOP while executing.
    thanks in advance

    No. You have to use a while loop.

  • Problem  in out from for loop

    Here i drew connect four board game which has 6 row and 7 columns . There is an additional row appear . How can i out from loop to not draw seven rows. ??
    import java.awt.Dimension;
    import javax.swing.JFrame;
    public class TestNet extends JFrame {
        private DrawingNet drawingNet;
        public TestNet() {
            drawingNet = new DrawingNet();
            getContentPane().add(drawingNet);
        public static void main(String[] args) {
            TestNet testNet = new TestNet();
            testNet.setDefaultCloseOperation(TestNet.EXIT_ON_CLOSE);
            testNet.setSize(new Dimension(600, 300));
            testNet.setLocationRelativeTo(null);
            testNet.setVisible(true);
            testNet.setExtendedState(MAXIMIZED_BOTH);
    import java.awt.Color;
    import java.awt.Graphics;
    import javax.swing.JPanel;
    class DrawingNet extends JPanel {
        private int X_START = 100, Y_START = 100, DISTANCE = 0;
        private static final int ROW = 6, COL = 7;
      //  private final int[][] arrayNet;
        public DrawingNet() {
        //    arrayNet = new int[ROW][COL];
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            for (int c = 0; c < COL; c++) {
    //            if (c ==7 ) {
    //                break;
                for (int r = 0; r < ROW; r++) {
    //                if (r == 5) {
    //                    break;
                    g.drawLine(X_START, Y_START + DISTANCE, X_START * COL, Y_START + DISTANCE);
                    g.drawLine(X_START + DISTANCE, Y_START, X_START + DISTANCE, Y_START * ROW);
                DISTANCE += 100;
    }Thanks

    if you compile my code you will see board consist of 6 row and seven column but there is seven row under the board i want not draw this
    how can i stop loop from drawing this row ??
    i do like this but also it is appear:
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            for (int c = 0; c < COL; c++) {  // col from 0 to 6  (7 columns)
                for (int r = 0; r < ROW; r++) {  // row from 0 to 5  (6 rows)
                    g.drawLine(X_START, Y_START + DISTANCE, X_START * COL, Y_START + DISTANCE);
                    g.drawLine(X_START + DISTANCE, Y_START, X_START + DISTANCE, Y_START * ROW);
                    if (r == 6) {  // the  goal from this to not draw  the seven row
                        continue;
                DISTANCE += 100;
        }Many thanks .
    Edited by: beshoyatefw on Mar 21, 2010 6:18 AM

  • Exclude from for loop

    Hi,
    I have this script and error :
    Declare
    Cursor C1 is
    select d.product_code,b.responsibility_key from FND_USER_RESP_GROUPS_ALL a,fnd_responsibility b,fnd_user c,fnd_application d
    where a.user_id = c.user_id
    and a.responsibility_id = b.responsibility_id
    and b.application_id = d.application_id
    and c.user_name ='SYSADMIN'; -- user you want to copy
    v c1%rowtype;
    BEGIN
    for v in c1 loop
    FND_USER_PKG.AddResp('MYUSER',v.product_code, v.responsibility_key,
    'Standard', 'DESCRIPTION', sysdate, null);
    end loop;
    END;
    ERROR at line 1:
    ORA-20001: APP-FND-02604: Invalide data
    APPLICATION_SHORT_NAME=OE, RESPONSIBILITY_KEY=ORDER_ENTRY_SUPER_USER,
    SECURITY_GROUP=Standard.
    ORA-06512: Ó "APPS.APP_EXCEPTION", ligne 70
    ORA-06512: Ó "APPS.FND_USER_PKG", ligne 2140
    ORA-06512: Ó ligne 11
    How can I exclude the case RESPONSIBILITY_KEY=ORDER_ENTRY_SUPER_USER,in my for v in c1 loop ? For example :
    if v.responsibility_key=ORDER_ENTRY_SUPER_USER then go to next.
    Many thanks.

    If I have understood it correctly...
    If you dont want to see this value at all, then probably by adding this condition to where clause of the select query (of the cursor). Or trying out something with parameterised cursors.
    Sidhu
    Message was edited by:
    Sidhu

  • Keyboard shortcut to pick a specific keyboard from the input menu

    Is it possible to switch to a particular international keyboard layout with a keyboard shortcut? I have a need for a number of layouts, so the built-in ability to cycle through them all is not convenient. I would like to be able to press a key combination and know that I've been taken to, say, Cyrillic, and use another set of keys for, say, Greek, etc.
    In the Keyboard and Mouse preference pane, I am actually able to specify keys for the various keyboards that I use by specifying the program "SystemUIServer" from /System/CoreServices. When I do this, the keyboard shortcuts I have picked appear in the Input Menu as if everything were going nicely. The menu lists various hotkeys as it should -- but they do nothing at all when the keys are actually pressed.
    I would be happy with anything that allows me to do what I want to do -- an automator script, say -- but so far I've had no luck. For the record, I have iKey on my system, but I cannot figure out how to control keyboard layouts there either.
      Mac OS X (10.4.7)  

    ..." In the Keyboard and Mouse preference pane, I am actually able to specify keys for the various keyboards that I use"...
    You're almost there - keyboard shortcuts assigned to menu items displayed on the right side of the screen won't trigger unless they are given keyboard focus. One way to do this is to use the keyboard shortcut for "Move focus to status menus in the menu bar" shortcut (see the "Keyboard & Mouse" pref pane). That key combo will switch focus to the first item on the left, and focus to other items can be gained by using the arrow keys. Once focus is on the "Input" menu, the assigned custom shortcut should work.
    To streamline the process, the "Move focus to status menu..." shortcut can be assigned to something more convenient, and the "Input" menu can be Cmd (⌘)-dragged to the left-most position. That way, it should be possible to switch to the desired input method using a relatively simple two-step keyboard combination.

  • Is it possible to pickup a specific file from a folder?

    Hi
    I am wondering whether it is possible to pick a specific file from a folder. I have a shape where I have got a filename and I need to look for it in a folder.
    Is that possible?
    And how can I achieve this? The next step is to pick the file up and transfer it to another location. So basically in pseudo code I need to ask my defined folder with a filename as parameter. Get the file and move it to another folder.
    Suggestions are most appreciated. Thanks

    Assuming you are using orchestration, you could
    create an assembly, install it in the GAC, add a reference to it in your BTS
    project, and call it from an Expression shape to resolve the receive
    location. You would only really need one static method in a class. Be sure
    to add a reference to Microsoft.BizTalk.ExplorerOM.dll.
    Example:
    using Microsoft.BizTalk.ExplorerOM;
    namespace Phil
    public class OrchestrationHelpers
    public static string ResolveReceiveLocationName(string
    inboundTransportLocation, string receivePortName)
    BtsCatalogExplorer bts = new BtsCatalogExplorer();
    bts.ConnectionString =
    "SERVER=localhost;DATABASE=BizTalkMgmtDb;Trusted_Connection=True;Network
    Library=DBMSSOCN;"
    foreach (ReceiveLocation location in
    bts.ReceivePorts[receivePortName].ReceiveLocations)
    if (location.Address == inboundTransportLocation) return location.Name;
    return null;
    In your Expression shape within your orchestration, assuming a message
    called "MyMessage" and a string variable "receiveLocationName":
    receiveLocationName =
    Phil.OrchestrationHelpers.ResolveReceiveLocationName(MyMessage(BTS.InboundTransportLocation),
    MyMessage(BTS.ReceivePortName));
    If this post answers your question, please mark it as such. If this post is helpful, click 'Vote as helpful'.

  • Statement error in for loop noobq

    Hi
    Could anyoe tell me why this wont work? Its supposed to count upp to tal in the first one and then count down from tal in the second and its the second one that dont work. I get a statement error for the text i put in between stars (supposed to be bold but i dont know..)
    thanks
    class r?knaa {
        public static void main(String[] args) {
            new r?knaa().run();
        void run() {
         int tal = Keyboard.nextInt ("Ange ett tal ? s? ska vi r?kna...(^_^): ");
         for (int upp = 1; upp <= tal; upp = upp + 1) {
             System.out.print ( upp+ " " );
         System.out.println (" ");
         System.out.println (" ");
         for (*tal*; tal > 0; tal = tal -1 ){
             System.out.print ( tal+ " " );
    }Edited by: gibitlib on Feb 19, 2010 3:02 PM

    jverd wrote:
    sharkura wrote:
    I assumed that it would decrement after the block of statements associated with the while loop, as is true with the for loop.Not sure what you mean by "as is true with the for loop", but I'm catching a hint of a very common misconception about the post-inc/dec operators.
    A LOT of people think that post-inc/dec means "last step in the statement" or "after everything else has been done" or something like that. That kind of thiiking is just black magic hocus pocus and serves no purposeI don't think I thiik like that, Jeff. I've never used a post-inc operator in a while loop. Certainly, if I felt a need to do so, I would test it, and try to understand why it works the way it does. Empirically, I know that given the following for loop:
    for ( int i = 0; i < limit; i++ )
      ... some statements
    }the incrementation of i occurs after the statements in the block execute. It may be specific to the for loop that the third statement in the for loop executes after the block of statements, in which case
    for ( int i = 0; i < limit; ++i )
      ... some statements
    }would work the same, and you can bet I will test that.
    I did make an assumption last night, and did not test it. That is not typical of me. I do resent somewhat the accusation of black magic hocus pocus. My last statement in that post was:
    sharkura wrote:
    I'll have to play with this some.Implicit in that remark was my intent to read more about pre/post decrementation and experiment until I more fully understood it. You have pointed out my lack of complete understanding, and, odd as it may seem, I appreciate that. I do log into these forums, partly, to improve my understanding of java.
    {?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Layout in Report: User Specific Indicator

    Hi Friends,
    I want to remove the "user Specific" Indicator from my layout and make it global but this indicator is in display mode. How can i do it? Please advice.
    Regards,
    CK

    Hi
    Which report are you refering to?
    Regards
    Sidi

  • How to pick up indices for a for loop

    hi guys , 
    i have a for loop with N = 60 , i'm trying to make something when the index (i) reachs specific number , the indecies i'm interested in are
    1 ,5 , 9,13, 17, 22, 26, ,30,34,38,43,47,51,55,59
    the difference is 4 in some of them but it changes to 5 @ 22 and 43 and come back to 4 in between .
    can anybody help me pick up these indecies ?

    Hi bmemq,
    You can do this with the Equal? function found in the Comparison palette. You would have one Equal? function for each index that you're interested in- one input would be a constant of that number and the other input will be the index terminal of the for loop. Next, you can you a Compound Arithmetic found in the Boolean palette. The number of inputs of the Compound Arithmetic can be expanded to match the number of indices that you're interested in, and each input will be the output of an Equal? function. Finally, the output of this Compound Arithmetic will be in the input of the selector in a Case Structure where you will have a true and false case to toggle the Boolean. 
    Josh Y.
    Applications Engineer
    National Instruments

  • I need to take elements from within 2 nested for loops and place them in an array at the specific row and column that I need.

    I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
    oes keep re-initializing my array.
    Attachments:
    Untitled.vi ‏26 KB

    I have fixed a number of things in your vi.
    You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    your_vi.vi.zip ‏13 KB

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • Issues with nested for loops - saving images from a camera

    Hi all,
    I've written a vi. to capture a specific number of images ('Image No') and save these images, outputted to a folder of my choice.  Each image is identified sequentially.  However, I wish to do a number of iterations ('Run') of this capture sequence, such that the filename of each image would be 'Filename (Run)_(Image No).png', e.g. run 5, image 10 would be 'Filename 5_10.png'.  I have tried a nested for loop for this but I receive an error 'Asynchronous I/O operation in progress' (I've attached a printscreen).
    Can anyone assist me in solving this problem? I preiously posted this in machine Vision but got no response (http://forums.ni.com/t5/Machine-Vision/Capturing-image-sequences-issues-with-nested-for-loops/m-p/19...).  Please find attached my vi.
    Kindest regards and thanks,
    Miika
    Solved!
    Go to Solution.
    Attachments:
    Labview problem.jpg ‏3841 KB
    Image sequence save to file.vi ‏48 KB

    Miika,
    the problem is not the filenam, but the name of the folder (AHHHHH!). You try to create the same folder in the outer for loop over and over again.... (it is the error message above the '======', not below )
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

Maybe you are looking for

  • Macbook doesn't wake up after automatic sleep

    I've got a problem with my macbook. Whenever it goes asleep from not using it ( automatic, I set the time at 15 minutes ) I need to push the power button for like 2 minutes before it wakes up again. I've many friends who have macbooks, whenever they

  • One prompt for two or more subject area

    Does someone knows how to resolve this problem? I have two subject areas. And I need to create prompt that will work on dashboard that contain requests from two different subject areas (one request from one subject area). I hope that I was clear with

  • Parsing List  in URL Variable for Query

    Hi, I am sending a url variable as in the following example: http://mypage.com/lookup.cfm?var=1001,1002,1003 I then need to query a database given the string "1001,1002,1003" in #URL.VAR# to find all records that contain those RecID numbers in my tab

  • Please help.... for hhk file

    guys i got an issue in robohelp 10 i had a project of toc in two languages, except the translation content rest all the links are perfectly equal to each other so once i created the toc in 1st language, for the 2nd i just replaced the source html fil

  • What's wrong with my JNI!

    The below is my code, DesEncrypt() is a function to encrypt data, and variable result will be returned by DES encrypting function. The question is that sometimes it will produce wrong result. For example, If I input data "111111111", the result maybe