While loop in a Hash Map

My while loop doesnt seem to work in a hash map, it works fine when I loop an array list.
It compiles but it doesnt seem to find any employees, should I use another loop?
{code
public Employee find(String id)
Employee foundEmployee = null;
int index = 0;
boolean found = false;
while(index < register.size() && !found){
Employee right = register.get(index);
String namn = right.getName();
if (namn.equals(id)){
foundEmployee = right;
found = true;
index++;
return foundEmployee;

A: while loop in a Hash Map

what if you looped on the key set?
  public Employee find(String id)
    Employee foundEmployee = null;
    Set<Integer> keySet = register.keySet();
    for (Integer key : keySet)
      Employee right = register.get(key);
      if (right.getName().equals(id))
        foundEmployee = right;
        break;
    return foundEmployee;
  }

what if you looped on the key set?
  public Employee find(String id)
    Employee foundEmployee = null;
    Set<Integer> keySet = register.keySet();
    for (Integer key : keySet)
      Employee right = register.get(key);
      if (right.getName().equals(id))
        foundEmployee = right;
        break;
    return foundEmployee;
  }

Similar Messages

  • While Loop in a mapping

    Can I do while loop in a mapping. I know I can do this in process flow but can I do it in a mapping.

    The OWB code generator produces a number of different code modes including set based SQL and various modes of row based code. In the row based code there are essentially (implicit) loops over the cursors, so there are implicit loops that you can do stuff, depends on what you are after.
    Cheers
    David

  • Extra Space coming while looping through Hash Set in JSP: URGENT

    Hi,
    I have to loop through the Hash Set in jsp, and display the contents with a comma seperated list.
    I am able to display the values withing the set, however.. after every value,
    i am getting an extra space and then a comma. How do i get rid of this extra space?
    Below is the code snippet
    <% Set tagSet = new HashSet();
         tagSet = (Set)request.getAttribute(PhotoConstants.REQ_RELATED_TAGS);     
         Iterator i = tagSet.iterator();     
         while(i.hasNext()){
         String tagName=(String)i.next();
    %>
    <a href="/outlook/photo/keywords?keywords=<%=URLEncoder.encode(tagName)%>"><%=tagName%></a>
    <%if(i.hasNext()==true){%>,<%}%>
    <%}%>
    I am getting following output:
    NY , sky , Sports & Recreation , clouds , New York City , New York
    Expected Output:
    NY, sky, Sports & Recreation, clouds, New York City, New York
    I want space after a comma, not befor comma...
    Any help is really appreciated..
    Thanks
    Deepti

    <% while(i.hasNext()) {
        String tagName=(String)i.next(); %>
        <a href="/outlook/photo/keywords?keywords=<%=URLEncoder.encode(tagName)
        %>"><%=tagName%></a><%if(i.hasNext()==true){ %>,<% } %>
    <% } %>I think this is an html whitespace thing... try moving your code around to look like what's above (ie move the end of line to inside your scriptlet tag)
    Code looks OK...

  • Question in ABAP syntax, read & insert data from internal table, while loop

    Hi, SDN Fellow.
    I am from Java background and learnt ABAP, I don't usually write much ABAP code.
    I am trying to implement the following logic in a RFC now.
    I have one z-custom database table, the structure as the following:
    It has two columns, with these sample data.
    Says datable table is ZEMPMGRTAB.
    EmployeeID,ManagerID
    user10,user1
    user9,user1
    user8,user1
    user7,user2
    user6,user2
    user5,user2
    user4,user2
    user2,user1
    The logic is this:
    I have a input parameter, userid. I am using this parameter to have a select statement to query the record into export table,EXPTAB 'LIKE' table ZEMPMGRTAB.
    SELECT * FROM  ZEMPMGRTAB
      into table EXPTAB
       WHERE  EMPLOYEEID  = USERID.
    Say, my parameter value, USERID ='USER4'.
    Referring to the sample data above, I can get the record of this in my EXPTAB,
    EmployeeID,ManagerID
    user4,user2
    Now, I want to iterately use the EXPTABLE-ManagerID
    as the USERID input in SELECT statement, until it has no return result. Then, insert the new records in
    EXPTAB.
    In above new loop case, we will get this table content in EXPTAB,
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    I kind of think of the pseudocode logic as below:
    (These may not be a valid ABAP code, so I need help to convert/correct them)
    DATA:
    IWA TYEP ZZEMPMGRTAB,
    ITAB
    HASHED TABLE OF ZZEMPMGRTAB
    WITH UNIQUE KEY EMPLOYEEID.
    SELECT * FROM  ZEMPMGRTAB
      into table ITAB
       WHERE  EMPLOYEEID  = USERID.
    *Question 1: I cannot insert a internal table to export table, it is *incompatible type, what is the alternative way fo this?
    *Question 2: How can I access thedata of the internal table like this,ITAB-MANAGERID? As if I can, I would do this:
    * IWA-EMPLOYEEE = ITAB-EMPLOYEEID. IWA-MANAGERID = IWA-MANAGERID. INSERT IWA INTO TABLE EXPTAB.
    * Question 3: Is the 'NE NULL' - 'not equal to NULL' is right syntax?
    IF ITAB NE NULL.
    INSERT ITAB INTO EXPTAB.
    ENDIF
    * Question 4: Is my WHILE loop setup right here? And are the syntax right?
    WHILE ITAB NE NULL.
    SELECT * FROM  ZEMPMGRTAB
      into table ITAB
       WHERE  EMPLOYEEID  = ITAB-MANAGERID.
    IF ITAB NE NULL.
    INSERT ITAB INTO EXPTAB.
    ENDIF
    REFRESH ITAB.
    ENDWHILE.
    Assume all the syntax and logic are right, I should get this result:
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    If I have a new entry in datable table,ZEMPMGRTAB like this:
    user1,user0
    My pseudocode logic will get this result:
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    user1,user0
    I truly appreciate if you can help me to validate the above syntax and pseudocode logic.
    Thanks in advance.
    KC

    Hi,
    FUNCTION ZGETSOMEINFO3.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(USERID) TYPE  AWTXT
    *"     VALUE(FMTYPEID) TYPE  AWTXT
    *"  EXPORTING
    *"     VALUE(RETURN) TYPE  BAPIRETURN
    *"  TABLES
    *"      APPROVERT STRUCTURE  ZTAB_FMAPPROVER
    *"      ACTOWNERT STRUCTURE  ZTAB_FMACTOWNER
    DATA: T_RESULT TYPE STANDARD TABLE OF ZTAB_FMAPPROVER.
    **Question 1: For this line, I got an error says "Program ''USERID" *not found. Is the syntax right, as the USERID is a parameter for the function.
    perform add_line(USERID).
      ENDFUNCTION.
    form add_line using i_user type ZTAB_FMAPPROVER.EMPLOYEEID
                        changing T_RESULT TYPE ZTAB_FMAPPROVER.
    data: ls_row type ZTAB_FMAPPROVER.
    * Get record for i_user
    select single * into ls_row from ZTAB_FMAPPROVER
    where EmployeeID = i_user.
    if sy-subrc NE 0.
    * Do nothing, there is not manager for this employee
    else.
    * Store result
    QUESTION 2: I am still got stuck on this line of code. It still *says that "T_RESULT" is not an internal table "OCCURS n" *specification is missing. I thought the line: "T_RESULT TYPE *ZTAB_FMAPPROVER" means declare internal table, T_RESULT as type of ZTAB_FMAPPROVER". Am I understand it wrongly?
    append ls_row to t_result.
    * Call recursion
    perform add_line using ls_row-ManagerID
                              changing t_result.
    endif.
    endform.
    Thanks,
    KC

  • Problem with while loops, please help!

    I am having quite a bit of trouble with a program im working on. What i am doing is reading files from a directory in a for loop, in this loop the files are being broken into words and entered into a while loop where they are counted, the problem is i need to count the words in each file seperately and store each count in an array list or something similar. I also want to store the words in each file onto a seperate list
    for(...)
    read in files...
         //Go through each line of the first file
              while(matchLine1.find()) {
                   CharSequence line1 = matchLine1.group();
                   //Get the words in the line
                   String words1[] = wordBreak.split(line1);
                   for (int i1 = 0, n = words1.length; i1 < n; i1++) {
                        if(words1[i1].length() > 0) {
                             int count= 0;
                                           count++;
                             list1.add(words1[i1]);
              }This is what i have been doing, but with this method count stores the number of words in all files combined, not each individual file, and similarly list1 stores the words in all the files not in each individual file. Does anybody know how i could change this or what datastructures i could use that would allow me to store each file seperately. I would appreciate any help on this topic, Thanks!

    Don't try to construct complicated nested loops, it makes things a
    tangled mess. You want a collection of words per file. You have at least
    zero files. Given a file (or its name), you want to add a word to a collection
    associated with that file, right?
    A Map is perfect for this, i.e. the file's name can be the key and the
    associated value can be the collection of words. A separate simple class
    can be a 'MapManager' (ahem) that controls the access to this master
    map. This MapManager doesn't know anything about what type of
    collection is supposed to store all those words. Maybe you want to
    store just the unique words, maybe you want to store them all, including
    the duplicates etc. etc. The MapManager depends on a CollectionBuilder,
    i.e. a simple thing that is able to deliver a new collection to be associated
    with a file name. Here's the CollectionBuilder:public interface CollectionBuilder {
       Collection getCollection();
    }Because I'm feeling lazy today, I won't design an interface for a MapManager,
    so I simply make it a class; here it is:public class MapManager {
       private Map map= new HashMap(); // file/words association
       CollectionBuilder cb; // delivers Collections per file
       // constructor
       public MapManager(CollectionBuilder cb) { this.cb= cb; }
       // add a word 'word' given a filename 'name'
       public boolean addWord(String name, String word) {
          Collection c= map.get(name);
          if (c == null) { // nothing found for this file
             c= cb.getCollection(); // get a new collection
             map.put(name, c); // and associate it with the filename
          return c.add(word); // return whatever the collection returns
       // get the collection associated with a filename
       public Collection getCollection(String name) { return map.get(name); }
    }... now simply keep adding words from a file to this MapManager and
    retrieve the collections afterwards.
    kind regards,
    Jos

  • SubVI with while loop + event structure not working in multi tab VI

    Hello Everyone,
    I am developing an interface for the control of a prober using Labview 2012, and I am stuck with some issue.
    To start with I provide you with a simplified version of my control interface VI, and with the sub-VI used to build and manage the wafer maps.
    The VI consists of several tabs: Prober Initialization, Wafer Handling, Wafer Map, Status, Error.
    The sub-VI can:
    1/ initialize the grid to display the map (sub VI Init Grid not provided here)
    2/ import XY coordinates from a txt file (sub VI Wafer Map Import)
    3/ display the coordinates and index of the die below the cursor
    4/ and when a die position is double clicked, and the boolean "Edit Wafer Map" is true, then the user can change the state (color) of the die between On-wafer die and Selected Die
    My issue:
    If I use the sub-VI by itself, it works fine. However when I use it as a sub-VI in the tab "Wafer Map", the map does not build up and I can no further use the embedded functionalities in the sub-VI.
    I suspect the while loop + event structure of the sub-VI to be the bottleneck here.
    However I don't know which way to go, that's why I'd be glad to have some advice and help here.
    Thank you.
    Florian
    Solved!
    Go to Solution.
    Attachments:
    Control Interface.zip ‏61 KB

    Hi NitzZ,
    Thank you for your reply.
    I tried to save the VIs in LV10, please tell me if you can open them now.
    Inside he event structure there is quite some code, and since I don't want to make the main vi too bulky, I would like to keep it as a sub-VI. 
    As you can see from the sub-VI, the event structure is used for extracting cursor position and tracking the double click action. These events are linked, through a property node, to the image "Wafer Map" which is passed to the main vi through connector pane.
    All values are passed this way as well (through connector pane). Is there another way?
    Maybe "refnum", but I don't really understand how to use them...
    If I use the event structure in the main vi, the wafer map is still not working. I tried it earlier.
    To implement the multi tab front panel, I used a tab control, and a for loop + case structure. For each element of the case structure, there is a corresponding action.
    For the case where I put the code (element=2) for Wafer Map, I also control the execution of the code with a case structure activated by the button "REFRESH". Otherwise I end up with a freezing of the panel right after the start.
    I hope these comments help you understand better.
    Regards,
    Florian
    Attachments:
    Control Interface.zip ‏104 KB

  • Sorting in List Hash Map

    Hi All ,
    I i have the data in below format:
    Name     Age     Skill     Company
    Vass     21     Java     Zylog
    Samy     24     PB     HP
    Lee     18     ADF     CTS
    Reng     16     Java     Info
    I converted this data into java collections List<Hash Map> like this.
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    public class HashMapDemo {
        public static void main(String[] args) {
            // Create a hash map
            List<HashMap> list = new ArrayList<HashMap>();
            HashMap hm = new HashMap();
            hm.put("Name", new String("Vass"));
            hm.put("Age", new Integer(21));
            hm.put("Company", new String("Zylog"));
            hm.put("skill", new String("Java"));
            list.add(hm);
            HashMap hm1 = new HashMap();
            hm1.put("Name", new String("Samy"));
            hm1.put("Age", new Integer(24));
            hm1.put("Company", new String("HP"));
            hm1.put("skill", new String("PB"));
            list.add(hm1);
            HashMap hm2 = new HashMap();
            hm2.put("Name", new String("Lee"));
            hm2.put("Age", new Integer(18));
            hm2.put("Company", new String("CTS"));
            hm2.put("skill", new String("ADF"));
            list.add(hm2);
            HashMap hm3 = new HashMap();
            hm3.put("Name", new String("Reng"));
            hm3.put("Age", new Integer(16));
            hm3.put("Company", new String("Info"));
            hm3.put("skill", new String("Java"));
            list.add(hm3);
            Iterator i = list.iterator();
            while (i.hasNext()) {
                System.out.println(i.next());
    } As per data (table format) i want to sort the data in Column level
    how can i to achieve ?.
    List<HashMap> is type of collection is help to me?
    Any idea?
    Thanks,
    Vass Lee

    Check out Comparator, and use Google to find examples on how to use it.
    http://download.oracle.com/javase/6/docs/api/java/util/Comparator.html
    Still sorting a collection of hashmaps is a bit odd design though. I think you want to create a simple class with properties in stead of a HashMap, then implement Comparable on that class.

  • How to create a dicitionary using hash map.

    Hi All,
    I want to create a dictionary using hash map where in i can add new words and there meaning. I have written some code But I am not happy with this. Can you suggest me how to add the words and there meanings to the hash map.
    I am not able to add the words and there meaning to the hash map.
    for this i tried creating a dictionary class.
    // Using hashmap
    import java.util.*;
    public class Dictionary
        public static void main(String[] args)
            // Create a hash map
            HashMap hm = new HashMap();
            // put elements to the map
            hm.put("Abode: ", "Home");
            hm.put("Balance: ", "An intrument to measure or weigh");
            hm.put("Car: ", "Automobile");
            hm.put("Dinner: ","Last meal of the day generally had after evening and before sleeping");
            hm.put("Embossed: ", "Engraved kind");
            Set set = hm.entrySet();
            Iterator i = set.iterator();
            while (i.hasNext())
                Map.Entry me = (Map.Entry) i.next();
                System.out.print(me.getKey() + ": ");
                System.out.println(me.getValue());
            System.out.println();
    }This is the other Dictionary class which i created.
    public class Main_Dictionary
        public static void main(String[] args)
            Content_Dictionary cd = new Content_Dictionary();
            cd.getContent_Dictionary("Abode", "Home");
            cd.displayValues();
    class Content_Dictionary
        String word, meaning;
        Content_Dictionary()
            word = "a";
            meaning = "b";
        Content_Dictionary(String x, String y)
            word = x;
            meaning = y;
        void getContent_Dictionary(String w, String m)
            word = w;
            meaning = m;
        void displayValues()
            System.out.print(word + ": ");
            System.out.println(meaning);
    }If i create an interface containing all the words and there meaning
    public interface Words_Dictionary
        String Abode = "Home";
        String Dark = "Lacking brightness";
        String Balance = "An intrument to measure or weigh";
        String Car = "Type of Automobile";
        String Dinner = "Last meal of the day";
        String Embossed  = "Engraved kind";
        String Adroit = "SkillFul";
    }and then create a another class which implements this interface, but how should i add these words and there meaning in the hashmap.

    I tried creating word document but i was unable to
    figure out how to do the operations on the word
    document and its content,
    So This is what i could come up with, i just created
    one class Dictionary , now I am able to search for
    the meaning of the word specified by me, and I am
    able to print all the words and there meanings added
    to the hashmap, but i am not able to figure out how
    to add a new word and the meaning in the hashmap and
    how to find is a word is there or not...May I suggest a slightly different approach?
    Do not create a String ==> String mapping, but a String ==> List<String> mapping. And do NOT place everything inside your main method.
    Here's a small demo:
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.List;
    public class Dictionary {
        private Map< String, List<String >> dictionary;
        public Dictionary() {
            dictionary = new HashMap< String, List<String >>();
        public void addWord(String base, String meaning) {
            List<String> allMeanings = dictionary.get(base);
            if(allMeanings == null) { // if null, there is no entry mapped to 'base' yet: create a new one
                List<String> newMeanings = new ArrayList<String>();
                newMeanings.add(meaning);
                dictionary.put(base, newMeanings);
            } else {
                allMeanings.add(meaning);
        public List<String> search(String base) {
            // your code here
            return null;
        // ... other methods ...
        public String toString() {
            StringBuilder strb = new StringBuilder();
            for(Map.Entry< String, List<String >> e : dictionary.entrySet()) {
                strb.append(e.getKey());
                strb.append(" : ");
                strb.append(e.getValue());
                strb.append('\n');
            return strb.toString();
        public static void main(String[] args) {
            Dictionary dict = new Dictionary();
            dict.addWord("Abode", "Home");
            dict.addWord("Abode", "House");
            dict.addWord("Car", "Automobile");
            dict.addWord("Car", "Vehicle");
            System.out.println(dict);
    }Good luck.

  • While loop issue

    I've been working on this assignment for a few days and got through my problem with the IF/ELSE IF statement. Now I am running into a problem with what I assume is some poor coding of my WHILE loops.
    I have this data file to input and read from:
    40      Light Karen L
    81       Fagan Bert Todd
    60       Antrim Forrest N
    95       Camden Warren
    52       Mulicka Al B
    89        Lee Phoebe
    75      Bright Harry
    92      Garris Ted
    43      Benson Martyne
    100       Lloyd Jeanine D
    73      Leslie Bennie A
    70      Brandt Leslie
    89      Schulman David
    90      Worthington Dan
    70      Hall Gus W
    50      Prigeon Dale R
    63      Fitzgibbons RustyMy code is as such:
    import java.io.*;
    import java.util.*;
    public class prgrm8
    { public static void main(String [] args) throws Exception
    { Scanner inFile = new Scanner(new FileReader("prgrm8.dat"));
         PrintWriter outFile = new PrintWriter("prgrm8.out");
              int value, ctr = 0, ctrR = 0;
              double sum = 0;
              String name = " ";
              String line = " ";
              String msg = " ";
              String filename = "prgrm8.dat";
              StringTokenizer st;
              outFile.println("REPORT");
         while(inFile.hasNextLine())
              line = inFile.nextLine();
              st = new StringTokenizer(line);
              value = Integer.parseInt(st.nextToken());
              name = st.nextToken();
         while(st.hasMoreTokens())
              name = name + " " + st.nextToken();
              st = new StringTokenizer(name);
              ctr++; 
         if(value >= 90){      
                   msg = "OUTSTANDING";
         }else{
         if(value >= 70){
                        msg = "Satisfactory";                                   
                         sum += value;
                        ctrR++;
         }else{
                        msg = "FAILING";
              outFile.println(value + " " + name + " " + msg);
              outFile.println(ctr + " " + "processed names");
              outFile.println(ctrR + " " + "between 70 and 89 inclusive");
         if(ctrR <= 0)
              outFile.close();
    }and I am outputing the following to my outFile:
    REPORT
    63 Fitzgibbons Rusty FAILING
    1 processed names
    0 between 70 and 89 inclusiveSo I am validating when compiling now, but I am not getting the intended results( I am wanting output each students grade, name, and the corresponding message, then get the total number of names processed(ctr), and then the number of grades between 70 and 79(ctrR) . Any advice is helpful, and thanks in advance!

    Here
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.io.Reader;
    import java.io.StreamTokenizer;
    import java.util.HashMap;
    public class Prog8 {
        public static void main(String[] args) {
            HashMap<String, Integer> map = new HashMap<String, Integer>();
            Reader r = null;
            StreamTokenizer st = null;
            PrintWriter pw = null;
            try {
                r = new BufferedReader(new FileReader("prgrm8.dat"));
                st = new StreamTokenizer(r);
            st.lowerCaseMode(false);
            st.eolIsSignificant(false);
            st.slashSlashComments(false);
            st.slashStarComments(false);
            String s = null;
            int i = 0;
                while (st.nextToken() != StreamTokenizer.TT_EOF) {
                    switch (st.ttype) {
                    case StreamTokenizer.TT_NUMBER:
                        i = (int) st.nval;
                        break;
                    case StreamTokenizer.TT_WORD:
                        s = st.sval;
                        break;
                    if (!map.containsKey(s) && !map.containsValue(i)) {
                        map.put(s, i);
                    } else {
                        System.err.println("Record already exist.");
                pw = new PrintWriter("prgrm8.out");
                int j = 0, k = 0, l = 0;
                for (String string : map.keySet()) {
                    if (map.get(string) >= 90) {
                        pw.println(map.get(string) + " " + string + "OUTSTANDING");
                        j++;
                    } else if (map.get(string) <= 89 && map.get(string) >= 70) {
                        pw.println(map.get(string) + " " + string + "PASSING");
                        k++;
                    } else {
                        pw.println(map.get(string) + " " + string + "FAILING");
                        l++;
                pw.println(j + " OUTSTANDING, " + k + " PASSING, and " + l + " FAILING");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    pw.flush();
                    pw.close();
                    r.close();
                } catch (IOException e) {
                    e.printStackTrace();
    }P.S. untested
    let me know.
    Edited by: Oclamora on May 15, 2010 6:56 PM
    spelling edit

  • JSTL While loop quick question

    Hi,
    I have a hashmap that contains the keys "number1", "number2" etc.... I want to loop through as long as the next key is not null, e.g.
    // Assume nextKey is the string "number1" and counter is 1
    while (myMap.get(nextKey) != null) {
       // do something
       counter++ ;
       nextKey = "number" + counter ;
    }How do I perform this boolean while loop? Would I need to use the forEach tag or a custom tag?
    Cheers.

    The easiest way to do this is to use the <c:forEach> tag providing your map as the 'items' attribute.
    Each iteration exposes an object of type Map.Entry which is one key-value pair in your underlying Map object. You can then use the getKey() and getValue() methods on the exposed Map.Entry object.
    <c:forEach items = "myMap" var = "eachEntry">
         Key is ${eachEntry.key}
         Value is ${eachEntry.value} <br>
    </c:forEach>If you have to supply the keys yourselves (in the above example, both the key and the value were discovered dynamically), then you still use the forEach tag.
    However in this scenario what you need is a loop that iterates a fixed number of times equal to the size of the map.
    For this you use the jstl function taglib. For example, the below post would output the size of the map.
    <%@taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%>
    ${fn:length(myMap)}You use the begin and end attributes of the forEach loop to loop a fixed number of times. The varStatus attribute provides a counter inside the loop. Thus
    <c:forEach begin = "0" end = "1" varStatus = "status">
        Counter : ${status.count}
    </c:forEach>would cause the loop to iterate twice printing Counter :1 Counter :2.
    Finally you need to set an attribute whose value is appended with the counter to evaluate the key.
    Combining all of these, your code would be
    <c:set var = "key" value = "number"/> //this value will be appended with the counter to evaluate the key
    <c:forEach begin="0" end = "${fn:length(myMap)}" varStatus="status">
         <c:set var = "nextKey" value = "${key}${status.count}"/>
         ${myMap[nextKey]}
    </c:forEach>Does that help?
    ram.

  • How to use one single boolean button to control a multiple while loops?

    I've posted the attached file and you will see that it doesn't let me use local variable for stop button, but I need to stop all the action whenever I want but more than one single button on the front panel would look ugly... The file represents the Numeric Mode of
    HP 5371A. thanks for your time
    Attachments:
    NUMERIC.vi ‏580 KB

    In order to use a local variable, you can change the mechanical action of stop button (Switch When Pressed will work), or create a property node for it and select values. You'll also have to do a lot of work changing those for loops into while loops so that you can abort them.

  • While loop doing AO/AI ... Performanc​e?

    Hi!
    I have been trying to get a VI to do concurrent Analog
    data in and out and both the input and output rates and
    waveforms can change while the VI is running. My problem
    is this:
    (a) If I try putting the read and write operations in
    separate while loops, one or the other loop will
    die in a buffer over/underrun.
    (b) If I put both into the same loop, then this works
    but I am limited in the choice of data-rate parameters
    because eventually one or the other DAQ VI will take
    too long.
    At this point I have only one loop and the buffers are big
    enough to hold 10 iteration. Every time one of the loops
    dies I reset it. Still this seems awkward. Is there a
    way of improving on the loop overhead and putting t
    he
    input and output in separate loops? Or any other way to
    improve performance?
    Rudolf

    Ok, I knew that ocurences did something useful but I am
    still a bit confused:
    * Can you set an occurrence for an output event. None
    of the examples I've seen say so but it looks like
    it should work
    * How do occurrences actually help with the "hanging"
    problem. Does the compiler see the occurrence in
    a loop and change the wait parameters?
    I looked at devzone but most of the stuff I found there,
    even the promising looking stuff was all about
    synchronizing and triggering, not about occurrences.
    Rudolf
    JB wrote:
    : Once in the read function, the program "hangs" until the number of
    : data points is in the buffer. The same applies to the write function.
    : This means that most of the time, your program is waiting.
    : To sol
    ve this problem, you must use DAQ occurrences (--> hardware
    : events).
    : For examples for using daq occurrences, type "daq occurrence" in the
    : search of the LabVIEW help or even better, at
    : http://zone.ni.com/devzone/devzoneweb.nsf
    : Hope this helps

  • Can not pass data after while loop

    Hello.
    I have created a VI for my experiment and am having problem passing data outside a while loop to save on an excel file. The VI needs to first move a probe radially, take data at 1mm increment, then move axially, take data radially at 1mm increment, then move to the next axial position and repeat. It would then export these data to an excel file. The VI is a little complicated but it's the only way I know how to make it for our experiment. I have tested it and all the motion works correctly, however I can not get it to pass the data after the last while loop on the far right of the VI where I have put the arrows (Please see the attached VI ). Is it because I'm using too many sequence, case, and while loops?  If so, what other ways can I use to make it export data to the excel file?
    Any help would be appreciated. 
    Thank you,
    Max
    Attachments:
    B.Dot.Probe.Exp.vi ‏66 KB

    Ummmm .... gee, I'm not even sure where to begin with this one. Your VI is well .... ummmm... You have straight wires! That's always nice to see. As for everything else. Well... Your fundamental problem is lack of understanding of dataflow programming. What you've created is a text program. It would look fantastic in C. In LabVIEW it makes my heart break. For a direct answer to your question: Data will not show up outside a while loop until the while loop has completed. This means your most likely problem is that the conditions to stop that specific loop are not being met. As for what the problem is, I don't even want to start debugging this code. Of course, one way to pass data outside of loops is with local variables, and hey, you seem to be having so much fun with those, what's one more?
    This may sound harsh, and perhaps be somewhat insulting, but the brutal truth is that what I would personally do is to throw it out and to start using a good architecture like a state machine. This kind of framework is easy to code, easy to modify, and easy to debug. All qualities that your code seems to lack.
    Message Edited by smercurio_fc on 08-17-2009 10:00 PM

  • Why writes LabVIEW only every 2 seconds the measured Value to a Excel (In a while loop with 100 ms tact)?

    Hi everybody,
    I use the myDAQ to measure speed, ampere, and voltage of a battery driven motor. (For Current measurement, i use a Sensor which outputs a 0-10 V signal). I placed all DAQ-Assitants in a while loop with a [Wait until next ms multiple] clock and set a value of 100 ms. I thougt, Labview will now write into my text file 10 times a second all values. In fact, as you can see in the attached text file, Labview only writes in a unsteady interval of 1-2 seconds a value, which is too less.
    The question: Did I do anything wrong, how can you create VI that writes you lets say 10 values a second into text file? Or is simply the DigitalMultimeter input of the myDAQ not able to sample a rate of 10 Hz? I couldn´t find any information in the specification handbook about the sample rate of the DMM?
    If anyone can help me would be great! Thanx a lot, Markus
    Attachments:
    Measure Speed+Current+Voltage into Excel.vi ‏175 KB
    Test7.txt ‏1 KB

    File I/O is not very efficient. I recommend that you do you file logging in a parallel task. Have one task do your data acquision. This task would then pass the data to be logged to the logging task via a queue. That way your file operations do not impact your data acquision. Also, express VIs are not very efficient. You would be better off accessing that directly using the DAQ VIs. The express VIs contain lots of steps that do not need to be done every time you call it such as initializing the device.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How can I reset the value of an indicator in a while loop, from another synchronous while loop?

    I am running 2 synchronous while loops, one which is keep track of time, and the other is measuring periods. In the while loop that is measuring periods, I have a boolean indicator displaying whether the signal is on or off. My problem is that when the signal is off, the VI I use to measure the periods is waiting for the next signal, and displays the boolean value from the previous period measurement. While this VI is waiting, I want the indicator to display false and not the value from the last iteration of the loop.
    I am using LV 5.1 for MAC.

    Two things you can try:
    In preface to the first, the most common (perhaps ONLY) use of local variables should be in transferring data between parallel loops. This is a matter of discipline, and creates programs that are easier to understand, take less time and memory, and are just plain cleaner. Having said that, to transfer data between loops, use a local variable.
    Second solution: Instead of setting the value to false, just hide the indicator in question by using control references (property nodes for prev. version of LabVIEW). Control references are a great way to control items on a dialog or HMI screen.

Maybe you are looking for