Is there arrays or FOR loops in ABAP?

Hi everyone!
Is there an array and FOR loops in ABAP similar to the C Language?
If there is, please give example. _
Thanks a lot!

Hi,
There is no array concept in ABAP but there are field-symbols which are same as pointers in C.As for the FOR loop there is no such command in SAP/ABAP but we do have the do..while and loop...endloop commands.There is also CASE statements and if..endif commands.
Thanks,
Sandeep.

Similar Messages

  • Convert array of clusters to cluster of arrays without for loop

    Hi!
    Here's a problem: I've got an array of clusters (array of messages). Each cluster consists of elements of different data types: double (time), cluster (parameters), char (station id), byte (message code). I know one cluster size and the array size. I need to draw a time graph. How can I convert the array of clusters to a cluster of arrays (array of time values, array of parameters clusters, arrays of chars and bytes).
    I post this question because in my real array of clusters each cluster consists of 162 elements and some of them are clusters themselves, so I realy dont want to wire "for" loops as was advised in other topics.
    Hope to get fresh ideas. Memory management? Type Cast? FlatternStrings and variants? Anything!
    Thank you. 

    Idea wrote:
    Hi, everybody! Glad you read the post! 
    There is the cluster in the attachment. The application I make is a TCP client. The cluster is a message. Actually I get a string, find edges ("DIAG" - begin, "GAID" - end) and then I use "unflattern to string" for making the cluster. I cann't make another structure of the message - I didn't make the server. My client has a buffer of recieved messages. I need to plot graphs of different cluster elements for all messages in my buffer (for example the Time 1 element). If I use the for loop it would be too slow. The idea was to convert all buffer to a 2D array of U8 and then use type cast to get the cluster of arrays. Then it would be easy to take ane cluster element and send it to graph.
    I didn't sucseed yet. 
    Idea. 
    What is your question about?
    A) convert the string you get from I don't know where to the giant cluster, the red part in your message, or
    B) making a graph out of some element from that giant cluster, who now is in an array, the blue part in your message.
    The code you showed us looks a solution for question A but no loop is needed for this. So why bother about a loop that would be too slow here?
    Also your code start from an array of U8, so where's the string?
    If you could provide a string that needs conversion, we could try another way ... ...
    Question B can easily be solved with a for loop and "unbundle by name". Don't know where you get the idea that a loop would be too slow
    Open G library has a lot of VI's to retrieve specific elements from clusters, maybe one of those could help solve the problem.

  • Remove text field from Array via for loop

    Hi,
    i have a problem to remove text fields added via for loop.
    That im doing is, via for loop im dynamically creating menu with 10 buttons.
    Each button contain, dynamically created, background (shape) and text field.
    And everything is fine.
    But when im try to remove text fields then i got this error:
    - Im using button to remove text fields - lang_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
              at flash.display::DisplayObjectContainer/removeChild()
              at Loading_Img_fla::MainTimeline/xmlLoaded()
              at flash.events::EventDispatcher/dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at flash.net::URLLoader/onComplete()
    In the script bellow marked with red is what should remove text fields from an Array, instead giving me error.
    Here is my script
    // Create for loop
    for (var i:int = 0; i < 10; i++)
              for each (xml in listItems)
                        if (i == xml.attribute("Id"))
                                  // Add MovieClip to stage to hold the data
                                  addChild(lmHolder);
                                  lmHolder.x = 0;
                                  lmHolder.y = 0;
                                  // Create new MovieClip to hold buttons
                                  lmButtonsMCArray[i] = new MovieClip();
                                  lmButtonsMCArray[i].buttonMode = true;
                                  lmButtonsMCArray[i].mouseChildren = false;
                                  lmButtonsMCArray[i].x = 20;
                                  lmButtonsMCArray[i].y = 20 + btCount * buttonSpace;
                                  // Add each button MovieClip to lmHolder MovieClip
                                  lmHolder.addChild(lmButtonsMCArray[i]);
                                  // Create Background to buttons
                                  lmButtonsArray[i] = new Shape();
                                  lmButtonsArray[i].graphics.beginFill(lmBgColor0, 1);
                                  lmButtonsArray[i].graphics.drawRect(0, 0, 230, 85);
                                  lmButtonsArray[i].x = 0;
                                  lmButtonsArray[i].y = 0;
                                  // <<-- Add Background shape to the buttons MovieClips
                                  lmButtonsMCArray[i].addChild(lmButtonsArray[i]);
                                  // Create a new array to preserve data from XML List
                                  lmNameArrayEG = new Array();
                                  lmNameArrayUS = new Array();
                                  // Create local variable to hold
                                  var lmTxtFieldContentUS:String;
                                  var lmTxtFieldContentEG:String;
                                  var lmTxtContent:String;
                                  // If clicked button is EG then make array with Arabic text
                                  // If clicked button is US then make array with English text
                                  if (footer.lang_btn.langState == "EG")
                                            for each (var leftMenuName:XML in egLanguageList)
                                                      lmNameArrayEG.push(leftMenuName);
                                            lmTxtFieldContentEG = lmNameArrayEG[i];
                                            lmTxtContent = lmTxtFieldContentEG;
                                  else
                                            for each (var leftMenuNameUS:XML in usLanguageList)
                                                      lmNameArrayUS.push(leftMenuNameUS);
                                            lmTxtFieldContentUS = lmNameArrayUS[i];
                                            lmTxtContent = lmTxtFieldContentUS;
                                  // Setup new text field each time script is executed
                                  lmTxtFieldsArray[i] = new TextField();
                                  lmTxtFieldsArray[i].width = 110;
                                  lmTxtFieldsArray[i].border = false;
                                  lmTxtFieldsArray[i].wordWrap = true;
                                  lmTxtFieldsArray[i].multiline = true;
                                  lmTxtFieldsArray[i].selectable = false;
                                  lmTxtFieldsArray[i].embedFonts = true;
                                  lmTxtFieldsArray[i].antiAliasType = AntiAliasType.ADVANCED;
                                  lmTxtFieldsArray[i].autoSize = TextFieldAutoSize.CENTER;
                                  lmTxtFieldsArray[i].text = lmTxtContent.toUpperCase();
                                  lmTxtFieldsArray[i].x = 10;
                                  lmTxtFieldsArray[i].name = "lmTxtFieldName" + i;
                                  // <<-- Add Text fields to the Movie Clip
                                  lmButtonsMCArray[i].addChild(lmTxtFieldsArray[i]);
                                  // If clicked button is EG then set Arabic text format, and make array with Arabic text fields
                                  // If clicked button is US then set English text format, and make array with Egnlish text fields
                                  if (footer.lang_btn.langState == "EG")
                                            lmTxtFieldsArray[i].setTextFormat(txtFormat_lm_eg);
                                            // Make array from text fields;
                                            pushEgTFintoArray.push(lmTxtFieldsArray[i]);
                                  else
                                            lmTxtFieldsArray[i].setTextFormat(txtFormat_lm_us);
                                            // Make array from text fields;
                                            pushUsTFintoArray.push(lmTxtFieldsArray[i]);
                                  // If clicked button is EG then loop thrue the for loop and remove English text fields from array
                                  // If clicked button is EG then loop thrue the for loop and remove Arabic text fields from array
                                  if (footer.lang_btn.langState == "EG")
                                            for (var rNr_us:Number = 0; rNr_us < pushUsTFintoArray.length; rNr_us++)
                                                      //remove the text field array from the display
                                       removeChild(pushUsTFintoArray[rNr_us]);
                                            //clear the array
                                            pushUsTFintoArray = [];
                                  else
                                            for (var rNr_eg:Number = 0; rNr_eg < pushEgTFintoArray.length; rNr_eg++)
                                                      //remove the text field array from the display
                                       removeChild(pushEgTFintoArray[rNr_eg]);
                                            //clear the array
                                            pushEgTFintoArray = [];
              btCount++;

    it looks like those tf's are children of  lmButtonsMCArray[i], not the current scope.  use:
    if (footer.lang_btn.langState == "EG")
                                            for (var rNr_us:Number = 0; rNr_us < pushUsTFintoArray.length; rNr_us++)
                                                      //remove the text field array from the display
                                        lmButtonsMCArray[rNr_us].removeChild(pushUsTFintoArray[rNr_us]);
                                            //clear the array
                                            pushUsTFintoArray = [];
                                  else
                                            for (var rNr_eg:Number = 0; rNr_eg < pushEgTFintoArray.length; rNr_eg++)
                                                      //remove the text field array from the display
                                        lmButtonsMCArray[rNr_eg].removeChild(pushEgTFintoArray[rNr_eg]);
                                            //clear the array
                                            pushEgTFintoArray = [];

  • Build 1D array using for loop

    Hi guys,
    I am testing out array. How do I create a 1D array of x-y using for loop?

    Nextal wrote:
    I am testing out array. How do I create a 1D array of x-y using for loop?
    OK, first of all you did not say what the array should contain. If you want an array that has one array element for each iteration of the while loop, you need to first think a bit harder. Your outer loop has no wait, thus it will spin millions of times per second and you will run out of memory soon, no matter how much memory you have. How many times should the while loop iterate? If you know the number before the program starts, you would use a FOR loop and autoindex at the loop boundary.
    If you want to use a whiile loop, you need a mechanism to keep the array size reasonable. For small final arrays, you can just build the array in a shift register if you need it updated as it happens. If you only need the array after the loop stops, you can autoindex at the right loop boundary.
    In any case, you should take a step back and decide what you really want. Currently the specifications are very vague and unreasonable.
    LabVIEW Champion . Do more with less code and in less time .

  • How do i use Arrays and For Loops in Loading Multiple Images?

    I am struggling to load a sequential array of images to appear like a moving image. So when u click the button the images load one after the other.
    The code below is what i have so far, but it fails to do what i seek in that there's only one image loading which is the last image in the array, so either because the images are stacking up atop each other, or because i simply dont understand the basics...
    And, i am unclear about what you said kglad, that my solution will be more complicated because i need to preload my image sequence and then use a loop to load it?
    import flash.net.URLRequest;
    import flash.display.Loader;
    var count:int = 0;
    var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg",
    "8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
    for(var i:uint=0;i<imageArray.length;i++){
    var btn:YourButton=new YourButton();
    btn.ivar=i;
    addChild(btn);
    btn.x=0;
    btn.y=0;
    btn.addEventListener(MouseEvent.CLICK,clickF);
    var ldr:Loader=new Loader();
    addChild(ldr);
    ldr.x=20;
    ldr.y=20;
    function clickF(e:MouseEvent){
        ldr.load(new URLRequest("D:/flash cs5.5/image_sequence/twirlSeq/"+imageArray[e.currentTarget.ivar]));
    function loadComplete(e:Event){
         // first process loaded image, then...
        count++;
        if(count < imageArray.length){
            loadCurrentImage();  // load the next image
        } else {
            // sequencial loading complete, carry on to next activity
    function loadCurrentImage(){
         ldr.load(imageArray[count]);
         ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

    create a new fla, add btn and add the code i suggested.  test.
    var count:int;
    var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7. jpg",
    "8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
    var ldr0:Loader=new Loader();
    ldr0.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
    var ldr1:Loader=new Loader();
    ldr1.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
    btn.addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent):void{
    // initialize count
    count=0;
    // call loadF
    loadF();
    function loadF():void{
    // add one of the loaders to the top of the displaylist and load the next image
    addChild(this["ldr"+count%2])
    this["ldr"+count%2].load(new URLRequest(imageArray[count]));
    function loadCompleteF(e:Event):void{
    // increment count
    count++;
    // check if the last has loaded
    if(count<imageArray.length){
    // if not clear the content out of the next loader.
    if(this["ldr"+count%2].content){
    this["ldr"+count%2].unloadAndStop();
    // and call loadF so the next loader can load the next image in the array
    loadF();
    } else {
    // if the last has loaded.
    // last load completed

  • FOR loop in ABAP Code ?

    Hi,
    I am working on a ABAP requirement, where I need to use a dynamic variable attached to a compilable code.
    For ex:
    In Jave we use
    for( i=0; i >n; i++){
    int i=0;
    stmti+stmti = result;
    Here  i  is an dynamic variable and it will be keep on changing ATTACHED TO stmti as stmt1.stmt2....etc. whenever there is a
    change in i.
    In ABAP, I have below code to attach:- Here I need to change from 1 to 100 like below. currently I see it as re-work, if i put the code each time changing manually. so I want make it in a loop and so dynamic and hence less code. How to achieve this. Please
    help. Any ABAP string functions to be used?
    if i=1
    DATA ls_nd_tmp1 TYPE wd_this->Element_nd_tmp1.
       DATA it_nd1 TYPE TABLE OF wd_this->Element_nd_tmp1.
       DATA wa_nd1 TYPE wd_this->Element_nd_tmp1.
    if i=2
    DATA ls_nd_tmp2 TYPE wd_this->Element_nd_tmp2.
       DATA it_nd2 TYPE TABLE OF wd_this->Element_nd_tmp2.
       DATA wa_nd2 TYPE wd_this->Element_nd_tmp2.
    Thanks
    Praveen
    Edited by: Praveen kumar Kadi on Sep 23, 2010 9:59 AM

    >
    Praveen kumar Kadi wrote:
    >
    > if i=1
    > DATA ls_nd_tmp1 TYPE wd_this->Element_nd_tmp1.
    >    DATA it_nd1 TYPE TABLE OF wd_this->Element_nd_tmp1.
    >    DATA wa_nd1 TYPE wd_this->Element_nd_tmp1.
    >
    > if i=2
    > DATA ls_nd_tmp2 TYPE wd_this->Element_nd_tmp2.
    >    DATA it_nd2 TYPE TABLE OF wd_this->Element_nd_tmp2.
    >    DATA wa_nd2 TYPE wd_this->Element_nd_tmp2.
    >
    What are you going to do with this data once you've defined it?  I'd define an internal table with three fields -
    TYPES: BEGIN OF my_elements_ty,
            r_element1 TYPE REF TO data,
            r_element2 TYPE REF TO data,
            r_element3 TYPE REF TO data,
          END OF my_elements_ty.
    DATA: lt_elements TYPE STANDARD TABLE OF my_elements_ty,
          ls_element  TYPE my_elements_ty.
    Then, for each iteration, build the name of the element type in strings and use something like:
    CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string1).   
    CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string2).   
    CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string3).
    INSERT ls_element INTO TABLE lt_elements.
    But this really is advanced ABAP, and not suitable for someone who is clearly a beginner. ( Also note that these forums are not supposed to be a substitute for training - or reading an ABAP tutorial ).
    matt

  • Añadir fila a array autoindexing for loop

    Hola a todos,
    Quería saber como puedo hacer para añadir una fila automaticamente a un array cada vez que se produce un cambio en mi array "Introducir datos". Creo que la solución es el tema de crear un bucle for y el autoindexing. Para que me entendais mejor he puesto en el vi adjunto un bloque que hace lo mismo que pretendo conseguir, pero teniendo que pulsar un botón.
    Muchas gracias
    Adjuntos:
    (Ejemplo).vi ‏8 KB

    Hola Davidll,
    Te adjunto un VI que añade una fila a una array cuando se cumple una condición. En este caso la condición es presionar un boton booleano.
    Fijate que hemos usado una variable local para escribir sobre la matriz que ya existe y simplemente con la función "Build array" añadimos una fila nueva con los valores de nuestro control "Fila a insertar" que noes más que una array de una dimension.
    Si tienes algún otro problema con arrays recuerda que dispones de una gran cantidad de ejemplos básicos en la pestaña Help/Find examples.. 
    Son bastante útlies y explicativos.
    PD:El boton esta configurado como "Latch when pressed" en la "Mechanical Action" para que solo produzca un pulo a nivel alto y velva a estado bajo. Sino produciria pulsos constantemente y se añadirian infinitas filas a nuestra array.
    Que pases buen día!
    Adjuntos:
    AddRowtoArray.vi ‏12 KB

  • Using while loops instead of for loops in arrays?

    I am new to java and doing a java tutorial on using arrays and for loops. What im trying to find out is how it is possible to use a while loop instead.
    I would be very grateful if anyone can suggest a way of changing my code to use a while loop.
    The code I have written is:
    public class DetermineGrade
    public static void main(String[]args)
    final char[] mark = {'A','B' ,'C' ,'D' ,'F' };
    char [] grade = new char[5];
    int [] Score ={95,35,65,75};
    for (int i=0; i<4; i++)
    if (Score >= 90)
    grade= mark[0] ;
    else if (Score >=80)
    grade = mark[1] ;
    else if (Score >=70)
    grade = mark[2] ;
    else if (Score >=60)
    grade = mark[3];
    else grade = mark[4];
    for (int i=0; i<4; i++)
    System.out.println("grade = " + Score + ", " + grade);
    Thankyou LB

    Im trying to underdstand the differences in the
    different loops. I can grasp the for loop but I dont
    see how a while loop works, or how it id different
    from the other?
    for (j = INIT; j < MAX; j++) {
        // do stuff
    }is the same as
    j = INIT;
    while (j < MAX) {
        // do stuff
        j++;
    }Lee

  • Help on changing array elements with For loop

    Hi,
    I'm wondering if anyone can help me with this problem.  I'd like to be able to modify elements of an array with For loop.  In the attached VI, my goal is to have an array of [0 1 2 3 4 5], but instead what I've got is [2 2 2 2 4 5].  I initialized the array with a value of 2 to help me identify which elements are changing.  Can anyone help me pointing where my mistake is?  Thanks.
    Peter
    Attachments:
    Array test.vi ‏19 KB

    It's a classic issue for LV newbies. In this case you HAVE to use a
    shift register otherwise the modifications of previous cicles are lost.
    It's all easier than it's seems, see attached vi.
    bye,
    manga
    Attachments:
    Array test 2.vi ‏19 KB

  • Stopping and Continuing a For Loop

    I have a problem on looping. This is a game of Whack the Mole. First, there is a for loop that is in charge of generating different hole positions for my moles. I want it so that the loop will (1) Generate a number (2) Stop the generating (3) Based on the number that was just generated, run a function for it. Once done running the function, then (4)Start the second round of generating another number......and it goes on for 9 rounds. I have my code here.
    var molePosX:Array = [166.90, 494.8, 810.7];
    var molePosY:Array = [282.55, 512.45, 730.35];
    var moleInUse:Boolean = false;
    if (moleInUse == false){
    for(var i:uint = 1; i<10; i++){
              var randomHole:Number = Math.floor(Math.random()*10)+1; //Generate 10 number
              trace(randomHole);
              switch (randomHole){
              case 1: trace("1");
              moleRun(molePosX[0],molePosY[0]);
              break;
              case 2: trace("2");
              moleRun(molePosX[1],molePosY[0]);
              break;
              case 3: trace("3");
              moleRun(molePosX[2],molePosY[0]);
              break;
              case 4: trace("4");
              moleRun(molePosX[0],molePosY[1]);
              break;
              case 5: trace("5");
              moleRun(molePosX[1],molePosY[1]);
              break;
              case 6: trace("6");
              moleRun(molePosX[2],molePosY[1]);
              break;
              case 7: trace("7");
              moleRun(molePosX[0],molePosY[2]);
              break;
              case 8: trace("8");
              moleRun(molePosX[1],molePosY[2]);
              break;
              case 9: trace("9");
              moleRun(molePosX[2],molePosY[2]);
              break;
              case 10: trace("10");
              break;
              function moleRun(xPos:Number,yPos:Number){
                        moleInUse = true;
                        var mole2:Mole = new Mole();
                        mole2.x = xPos;
                        mole2.y = yPos;
                        addChild(mole2);
                        moleInUse = false;
    Thank you very much!

    i'm not sure you want to do that without staggering your mole creation but if you do, you can use:
    var molePosX:Array = [166.90, 494.8, 810.7];
    var molePosY:Array = [282.55, 512.45, 730.35];
    createMoleF(9);
    function createMoleF(n:int):void{
    for(var i:uint = 0; i<n; i++){
              moleRun(Math.floor(Math.random()*molePosX.length),Math.floor(Math.random()*molePosY));
              function moleRun(xPos:Number,yPos:Number){
                        var mole2:Mole = new Mole();
                        mole2.x = xPos;
                        mole2.y = yPos;
                        addChild(mole2);
    Thank you very much!

  • For Loop with Error Check

    Hello all,
    As per my sample VI.
    I gave   Empty array to For Loop. As we know this Loop will not execute because N value “0”.
    But, I want to know why Error out always giving True value. This Error Indicator value changing to “True” irrespective of Error In.  
     BR,
    Munna
    Munna
    Solved!
    Go to Solution.

    That''s exaclty what I said.
    If you use plain tunnels and the loop iterates zero times, the output will give the default value for the datatype, which is FALSE for errors.
    If you use shift registers, whatever is wired to the initializer terminal will be output unchanged on the right if the loop iterates zero times. Since you initialize with a error=TRUE, that's what you get.
    This is all as expected. In your first post you claimed that the output is error=true using plain tunnels, which cannot be. Agreed?
    If you want error=false with the shift register, change the diagram constant accordingly.
    LabVIEW Champion . Do more with less code and in less time .

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Using a For loop to call one array element at a time

    I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.
    Adam

    adamoutlaw wrote:
    Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
    I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
    Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
    Message Edited by altenbach on 08-02-2007 07:14 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Indexing.png ‏4 KB

  • How to index array in a for loop

    i'm connecting from variant-to-data function to an index array function inside a for_loop (refer to attachment).  the data-type wire got converted from Table(2-D array) to Table(1-D array).  How do I keep it from converting to 1-D array?
    Attachments:
    arrayI.doc ‏146 KB

    Of course it seems you want to run the loop once for each row in the 2D array, so many times autoindexing is the better solution!
    You are using an "index array" inside the loop. If you are planning to wire the index to the iteration [i] terminal (who knows? ), you might as well use autoindexing. This way you don't need to wire N (the loop will know how many rows there are) and you don't need to use index array inside the loop.
    The image shows two functionally equivalent code fragments. Autoindexing (bottom) is much simpler than explicit indexing (top). See if autoindexing can work in your case.
    Since you are a LabVIEW beginner, you should try to stay way from stacked sequences and local variables. They are rarely needed and can ofter cause problems such as race conditions and unreadable code.
    Message Edited by altenbach on 03-31-2008 04:17 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    autoindexing.png ‏8 KB

  • Question about using for-loop to generate array from DAQmx. Thanks!

    I have a laser system with a frequency of 1kHz, I am using this 1kHz signal to trigger the DAQmx and get the data from a photodetector, e.g. I will get 1000 data points during 1 second from DAQmx, but I need to separate this 1000 data points into the even and odd list, which is two list of 500 data points, e.g.. The 1st, 3rd, ... 99th data is one array, the 2nd, 4th,... 10th data is another array, then I will do further calculations based on these two arrays.
    To seperate the even and odd data, the only way I can find is put these 1000 points into an array and then seperate them afterwards.
    Can I do things like this pic?
    I don't know the speed of the for loop, because the 1kHz trigger is always there, once it is triggered, the DAQmx read will give a data point, if the speed of the for-loop( the time from the end of a loop to the beginning of the next loop) is slower than the 1kHz trigger, then the for-loop will miss data point, then the ordering of the 1000 points in 1 second will be changed.
    Or I need to put everything, e.g. AI Voltage, Trigger, sample clock, into the for-loop and then return a Y? Thanks! 

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

Maybe you are looking for