For Loop in execDialog Description

Hi all,
I am using the Javascript execDialog function to create a dynamic popup to get some information from the user.  I have an array defined before the dialog and I need to be able to create a row that contains a checkbox and text area for each item in the array.  I'm not sure how I would/if I can use a for loop to do this.  I placed a For Loop around the entire thing but, of course, I end up getting one dialog box per array item which is not what I want.  I want a total of one dialog box with a variable number of rows.  Here's my code currently.  The area in red is what I need to perform the loop on and have it repeat for each element in my other array.  Please help - this is urgent!
var fundsDialog = {
description: {
     name: "Verify Current Info",
     elements:
               type: "cluster",
               align_children: "align_left",
               elements:
                         item_id:"main_text1",
                         type: "static_text",
                         name: "You indicated the following...",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         item_id:"main_text2",
                         type: "static_text",
                         name: "Name goes here",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         item_id:"main_text3",
                         type: "static_text",
                         name: "Please confirm the below items exist and uncheck any that don't apply.",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         type: "view",
                         align_children: "align_row",
                         elements:
                                   item_id:"box1",
                                   type: "check_box",
                                   //char_width: 30,
                                   height: 15,
                                   multiline: true,
                                   item_id:"text1",
                                   type: "static_text",
                                   name: itemToShow,
                                   font: "dialog",
                                   char_width: 30,
                                   height: 100,
                         type: "ok"

Hi,
You can pass in an array of dialog elements, so if you can build that up an array before the execDialog object.  Something like;
var o1 = [];
o1.push({
            item_id: "box1",
            type: "check_box",
            //char_width: 30,
            height: 15,
            multiline: true,
            item_id: "text1",
            type: "static_text",
            name: "Item 1",
            font: "dialog",
            char_width: 30,
            height: 100,
o1.push({
            item_id: "box2",
            type: "check_box",
            //char_width: 30,
            height: 15,
            multiline: true,
            item_id: "text2",
            type: "static_text",
            name: "Item 2",
            font: "dialog",
            char_width: 30,
            height: 100,
var fundsDialog = {
description: {
     name: "Verify Current Info",
     elements:
               type: "cluster",
               align_children: "align_left",
               elements:
                         item_id:"main_text1",
                         type: "static_text",
                         name: "You indicated the following...",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         item_id:"main_text2",
                         type: "static_text",
                         name: "Name goes here",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         item_id:"main_text3",
                         type: "static_text",
                         name: "Please confirm the below items exist and uncheck any that don't apply.",
                         bold: true,
                         font: "dialog",
                         char_width: 30,
                         height: 20,
                         type: "view",
                         align_children: "align_row",
                         elements: o1
                         type: "ok"
Does that help?
Bruce

Similar Messages

  • FOR LOOP cursor that updates table A based on a value in table B

    Hi,
    I need a FOR LOOP cursor that scans and updates all pro-rata column in table EMPLOYEE(child) based on what pay classification all employees are on in the CLASSIFICATION(parent) table.
    DECLARE
    BEGIN
    IF employee.emp_type = 'FT' THEN
    UPDATE employee
    SET employee.pro_rata = ((classification.yearly_pay/52)*52)
    WHERE employee.empid = v_empid AND classification.class_id = employee.class_id;
    END IF;
    IF employee.emp_type = 'PT1' THEN
    UPDATE employee
    SET employee.pro_rata = ((classification.yearly_pay/39)*52)
    WHERE employee.empid = v_empid AND classification.class_id = employee.class_id;
    END IF;
    IF employee.emp_type = 'PT2' THEN
    UPDATE employee
    SET employee.pro_rata = ((classification.yearly_pay/21)*52)
    WHERE employee.empid = v_empid AND classification.class_id = employee.class_id;
    END IF;
    END;
    How do I create a cursor that cuts across these two table
    See tables and data
    CREATE TABLE CLASSIFICATION(
    CLASS_ID VARCHAR2(6) NOT NULL,
    CLASS_TYPE VARCHAR2(10),
    DESCRIPTION VARCHAR2(30) NOT NULL,
    YEARLY_PAY NUMBER(8),
    HOURLY_RATE NUMBER,
    WEEKDAY_OVER_TIME NUMBER,
    WEEKEND_OVER_TIME NUMBER,
    CONSTRAINT PK_CLASS_ID PRIMARY KEY (CLASS_ID));
    INSERT INTO CLASSIFICATION VALUES('PR1','PERMANENT','MANAGER',45000,'','',NULL);
    INSERT INTO CLASSIFICATION VALUES('PR2','PERMANENT','ADMIN ASSISTANT',22000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR3','PERMANENT','CONTROLLER',32000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR4','PERMANENT','CASH OFFICER',22000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR5','PERMANENT','CLEANERS',16000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR6','PERMANENT','ADMIN OFFICER',22000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR7','PERMANENT','WAREHOUSE ATTENDANT',20000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR8','PERMANENT','WINDOWS DRESSER',22000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('PR9','PERMANENT','DIRECTOR',60000,'','',NULL);
    INSERT INTO CLASSIFICATION VALUES('PR10','PERMANENT','DEPUTY DIRECTOR',52000,'','',NULL);
    INSERT INTO CLASSIFICATION VALUES('PR11','PERMANENT','SALES ASSISTANT',21000,'',1.5,NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP2','TEMP STAFF','ADMIN ASSISTANT','',16.50,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP3','TEMP STAFF','CONTROLLER','',29.00,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP4','TEMP STAFF','CASH OFFICER','',19.00,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP5','TEMP STAFF','CLEANERS','',10.00,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP6','TEMP STAFF','ADMIN OFFICER','',20.00,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP7','TEMP STAFF','WAREHOUSE ATTENDANT','',18.00,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP8','TEMP STAFF','WINDOWS DRESSER','',18.50,'',NULL);
    INSERT INTO CLASSIFICATION VALUES('TEMP11','TEMP STAFF','SALES ASSISTANT','',16.00,'',NULL);
    CREATE TABLE EMPLOYEE(
    EMPID NUMBER(5) NOT NULL,
    SURNAME VARCHAR2(30) NOT NULL,
    FNAME VARCHAR2(30) NOT NULL,
    GENDER CHAR(1) NOT NULL,
    DOB DATE NOT NULL,
    EMP_TYPE VARCHAR2(20) NOT NULL,
    ANNUAL_WEEKS_REQD NUMBER(2),
    PRO_RATA_WAGES NUMBER(7,2),
    HOLIDAY_ENTLMENT NUMBER(2),
    SICK_LEAVE_ENTLMENT NUMBER(2),
    HIRE_DATE DATE NOT NULL,
    END_DATE DATE,
    ACCNO NUMBER(8) NOT NULL,
    BANKNAME VARCHAR2(20) NOT NULL,
    BRANCH VARCHAR2(20) NOT NULL,
    ACCOUNTNAME VARCHAR2(20),
    CLASS_ID VARCHAR2(6),
    CONSTRAINT CK_HIRE_END CHECK (HIRE_DATE < END_DATE),
    CONSTRAINT CK_HIRE_DOB CHECK (HIRE_DATE >= ADD_MONTHS(DOB, 12 * 18)),
    CONSTRAINT CK_EMP_TYPE CHECK (EMP_TYPE IN ('FT','PT1','PT2','PT3','HOURLY')),
    CONSTRAINT CK_EMP_GENDER CHECK (GENDER IN ('M','F')),
    CONSTRAINT FK_EMP_CLASS FOREIGN KEY (CLASS_ID) REFERENCES CLASSIFICATION(CLASS_ID),
    CONSTRAINT PK_EMP PRIMARY KEY (EMPID));
    CREATE SEQUENCE SEQ_EMPID START WITH 1;
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'RICHARD','BRANDON','M','25-DEC-1966','FT',52,22000.00,28,14,'10-JAN-2005',NULL,90823227,'NATWEST','BROMLEY','DEPOSIT','PR2');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'BOYCE','CODD','M','15-JAN-1972','PT1','','','','','12-JAN-2005',NULL,72444091,'LLOYDS','KENT','CURRENT','PR8');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'ALHAJA','BROWN','F','20-MAY-1970','HOURLY','','','','','21-JUN-2000',NULL,09081900,'ABBEY','ESSEX','CURRENT','TEMP2');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'RON','ATKINSON','M','10-AUG-1955','PT3','','','','','12-JAN-2005','26-MAR-2006',01009921,'HALIFAX','KENT','SAVINGS','PR6');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'CHAMPI','KANE','F','01-JAN-1965','PT2','','','','','12-JAN-2004',NULL,98120989,'HSBC','ILFORD','CURRENT','PR4');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'NED','VED','M','15-JAN-1980','HOURLY','','','','','29-DEC-2005',NULL,90812300,'WOOLWICH','LEWISHAM','CURRENT','TEMP6');
    INSERT INTO EMPLOYEE VALUES(
    SEQ_EMPID.NEXTVAL,'JILL','SANDER','F','22-MAR-1971','FT','','','','','30-NOV-2003',NULL,23230099,'BARCLAYS','PENGE','DEPOSIT','PR1');
    Any contribution would be appreciated
    many thanks
    Cube60

    Hi,
    I have triede this cursor procedure but I get an compilation error.
    See first post for tables and data..
    Can someone help me out please.
    SQL> CREATE OR REPLACE PROCEDURE update_employee(
    2 p_empid employee.empid%type,
    3 p_emp_type employee.emp_type%type)
    4 IS
    5 CURSOR c1 is
    6 select e.empid, e.emp_type, c.yearly_pay from employee e, classification c where
    7 c.class_id = e.class_id;
    8 BEGIN
    9 OPEN c1
    10 LOOP
    11 FETCH c1 INTO p_empid, p_emp_type;
    12 exit when c1%notfound;
    13
    14 IF v_emp_type ='PT1' THEN
    15 UPDATE employee SET annual_weeks_reqd = 39, pro_rata_wages = ((v_yearly_pay/52)*39), holiday_en
    tlment=21, sick_leave_entlment = 10.5 WHERE c.class_id = e.class_id;
    16 END IF;
    17 END;
    18 /
    Warning: Procedure created with compilation errors.
    SQL> SHOW ERR;
    Errors for PROCEDURE UPDATE_EMPLOYEE:
    LINE/COL ERROR
    10/1 PLS-00103: Encountered the symbol "LOOP" when expecting one of
    the following:
    . ( % ; for
    The symbol "; was inserted before "LOOP" to continue.
    Many thanks

  • How to code a parallel 'for loop' and 'while loop' where the while loop cannot terminate until the for loop has finished?? (queues also present)

    I've attached a sample VI that I just cannot figure out how to get working the way that I want.  I've labeled the some sections with black-on-yellow text boxes for clarity during the description that follows in the next few sentences.  Here's what I want:
    1) overall -- i'm intend for this to be a subVI that will do data acquisition and write the data to a file.  I want it to use a producer/consumer approach.  The producer construct is the 'parallel for loop' that runs an exact number of times depending on user input (which will come from the mainVI that is not included).  For now I've wired a 1-D array w/ 2 elements as a test case.  During the producer loop, the data is acquired and put into a queue to be delt with in the consumer loop (for now, i just add a random number to the queue).
    2) the consumer construct is the 'parallel while loop'.  It will dequeue elements and write them to a file.  I want this to keep running continuously and parallel until two conditions are met.
          i. the for loop has finished execution
          ii. the queue is empty.
       when the conditions are met, the while loop will exit, close the queue, and the subVI will finish. (and return stuff to mainVI that i can deal with on my own)
    Here's the problems.
    1)  in the "parallel for loop" I have a flat sequence structure.. I haven't had time to incorporate some data dependency into these two sequential sections, but basically, I just care that the "inner while loop" condition is met before the data is collected and queued.  I think I can do this on my own, but if you have suggestions, I'm interested.
    2)  I can easily get the outer for and while loops to run sequentially, but I want them to run in parallel.  My reasoning for this is that that I anticipate the two tasks taking very different amounts of time. .. basically, I want the while loop to just keep polling the queue to get everything out of it (or I suppose I could somehow use notifiers - suggestions welcome)...  the thing is, this loop will probably run faster than the for loop, so just checking to see that the queue is empty will not work... I need to meet the additional condition that nothing else will be placed in the queue - and this condition is met when the for loop is complete. basically, I just can't figure out how to do this.
    3) for now, I've placed a simple stop button in the 'parallel while loop', but I must be missing something fundamental here, because the stop button is totally unresponsive.  i.e. - when I press it, it stays depressed, and nothing happens.
    suggestions are totally welcome!
    thanks,
    -Z
    Attachments:
    daq01v1.vi ‏59 KB

    I'd actually like to add a little more, since I thought about it a bit and I'm still not quite certain I understand the sequence of events...
    altenbach wrote:
    zskillz wrote:
    So i read a bit more about the 'dequeue element' function, and as I understand it, since there is no timeout wired to the dequeue element function, it will wait forever, thus the race condition I suggested above can never happen!
    Yes, you got it!
    As I've thought about it a bit more, there's a few things that surprise me... first, the reason the 'dequeue element while loop' errors is not because there's nothing in the queue, it's becaues the queue has been released and it's trying to access that released queue...   However the problem I have is this --- Even though there's no timeout wired to the dequeue element, I still would think that the while loop that contains it would continue to run at whatever pace it wanted -- and as i said before.. most of the time, it would find that there is nothing to dequeue, but once in a while, something is there.  however, it seems that this loop only runs when something has been enqueued.  the reason I say this is illustrated in the next code sample MODv2 that's attached below.  I've added a stop button to the "queue size while loop" so the program runs until that is pressed.  I've also added a simple conditional in the "dequeue while loop"  that generates a random number if it a button is pressed... but this button is totally non-responsive... which means to me that the "dequeue while loop" isn't actually continuously running, but only when an element is added to the queue.  this still seems almost like the 'dequeue while loop" waits for a notifier from the queue telling it to run.  can you explain this to me? because it is different from what I expect to be happening.
    rasputin wrote:
    I tried to open your VIs but it doesn't work. LV
    is launched, the dialog box (new, open, configure...) opens and then...
    nothing. Not even an error message. I guess it isn't a problem of LV
    version or a dialog box would appear saying this. Could you, please,
    send a image of the code?
    Thanks,
    Hi Rasputin, I'm using LV8.  I assume that was your problem, but who knows.  I've attached a pic of of altenbach's solution since it's what I needed.
    thanks
    -Z
    Message Edited by zskillz on 10-20-2006 11:49 AM
    Attachments:
    daq01v1MODv2.vi ‏63 KB
    daq01v1MODpic.JPG ‏116 KB

  • How to get the elements out of a for loop simultaneously during the loop execution

    Hi, 
    I am student. I would like to know how to get the counter values outside the For loop parallely while the loop runs rather that getting the finally value outside the For loop. Looking forward for answers.
    Thanks,
    Athira
    Solved!
    Go to Solution.

    You could use a notifier (since it is a single value) or a reference (with a property node) to a control that gets the value elsewhere in another VI.
    If it is within the same VI, you could use a property node (right click > create > property node > value) from the control within the same VI located outside the loop.
    If you promiss NOT to abuse the use of Local Variables, you could use that to only write from ONE location within the For Loop to a control outside the loop, similar to the property node mentionned earlier.  (Of course, I will be struct by lightening for mentionning that and scolded by other LabVIEW coders for having a change of heart on the use of Locals....  Shivers are already crawling up my spine).
    You could use a queue, but that might be an overkill, unless:  the count is generated faster than it is being read elsewhere...
    As crossrulz mentionned, can you describe what you will be doing with the count?  Because synchronizing data (fresh / stale / etc) is very important within LabVIEW as it executes based on dataflow rather than a sequential order.
    Hope this helps. 
    EDIT: 
    You have not fully provided the answer.  We figured that much of your code from your description, but what is reading the value of the count?  Is it in a separate loop?  If not, it may only deal with the first value, which is likely 0.  The proper advice depends on how you process the received data (count).

  • The speed of the "for loop iteration"

    Hi all:
    I have written a short mini program just to test out the speed of a "for loop iteration"
    package generator;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
      private static long tmp = 0;
      public static int count=0;
      public synchronized long getValue(){
          long value = 0;
        value = 10 * System.currentTimeMillis();
        if(value == tmp){
          value++;
          count++;
        tmp = value;
        return value;
      public static void main(String[] args) {
       for (int i=0;i<1000;i++){
          getValue();
        System.out.println("count is " + count);
    }And i find that on average, count will be a value between 498-500, which probably means that on average the speed of a for loop is around 0.5 ms. But I guess the speed of the "for loop " iteration is also very much CPU dependent, could somebody possibly give me some education on this issue :) ?
    Also, anybody know exactly how System.currentTimeMillis works? For example, how does it get the current time from the OS, etc. let me know.
    Again, Many many thanks...

    Hi all:
    I have written a short mini program just to test out the speed of a "for loop iteration"You will find the overhead of the getValue() call, the increments and most importantly the System.currentTimeMillis() is what you are timing.
        public static void main(String args[])  {
            int ITER = 1000000000;
            long start = System.currentTimeMillis();
            for(int i=0;i<ITER;i++);
            long end = System.currentTimeMillis();
            System.out.println("Iterations per sec="+ITER*1000L/(end - start));
        }Prints the following Iterations per sec=576368876Running on a 1.8 GHz Intel/Windows2000

  • Synchronizing 2 tables ? merge ? or for loop ?

    Hi
    I have 2 tables
    Books(book id, description, price)
    New_books(book_id, description, price, is_synced, status)
    The new books tables as u can see have 2 additional columns. Every end of the day I have to check the status of the new_books. If it is ‘insert’ then I have to insert that particular record to the books table. if it is update, the new values should be updated in books tables. And same to delete. Finally when the relevant change is happened, I have to make the is_synced column as ‘1’ so that it makes sure that the record has been processed into the books tables.
    There are 1000+ records in the books table but in new_books its around 20+ records per day. The pk is book_id.
    Also sometimes, here might be records already existing in the books table even if the status of new_books is ‘insert’ in that case again we have to run an update and make sure that the particular book has new values taken from the new_books table.
    Can u folks suggest any approaches ?
    Will merge work ? will for loop work ? which is the best ? any other spolurtions ? if u can provide any pl/sql example, it would be great.
    noviceDBA

    I would probably go for a MERGE into the books table and a subsequent update of the new table.
    If the aim is to merge and update all of the records in new_books for which is_synched is not set to "1" then be aware that between starting the MERGE and starting the UPDATE there is a very small time window in which another session could theoretically commit the insert of a new record into the NEW_BOOKS table. To avoid this you can temporarily change the isolation level of your session: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_sqlproc.htm#i1025370. Use SERIALIZABLE to ensure that the UPDATE sees exactly the same data set in NEW_BOOKS as the MERGE did.
    there are a few other approaches you could use instead, of course -- locking the table, for example.

  • Truncating an array within a for loop

    I'm currently working with a program that builds an array of 3000*N real numbers, where N is a control that I specify. I want to pass this array into a for loop that runs N times, each time splitting the first 3000 numbers of the array. So, in other words I want the for loop to execute enough times such that the initial array will be completely divided into groups of 3000 when I'm finished. Later I'll be finding the maximum value of all of these subarrays and taking the average of those. What I tried first is to pass the array into the for loop, then truncate it at index = 3000, but the problem is that I can't hard code the loop to do this N times. Any advice or other methods you'd recommend for doing this?
    Thanks.
    Message Edited by Robtn on 03-05-2010 03:17 PM

    Mark--I don't think I can use that approach. Let me be more specific on what the problem is:
    Our "big program" is a giant while loop that constantly reads in voltage values from a DAQ assistant.
    It has two modes, the first of which I'm having a lot of trouble with. This mode uses a for loop (N = 3000) nested within the giant while loop.
    When the for loop activates, the DAQ assistant takes reads 300 samples for every iteration and takes the maximum of those 300 values. It then builds an array composed of all the maxima. After the for loop has executed 3000 times, a case structure activates, which then finds the maximum of the array of maxima.
    I want this (N=3000) for loop to execute an arbitrary number of times, a number that I will specify. Each of those times it should generate a completely seperate array of maxima. So, if I want the for loop to run 5 times, I want 5 different arrays.
    My approach for doing this was to change N=3000 to say N = 15000, then split up the resulting array 5 times. So, I need an entirely separate for loop that reads in this array of 15000 maxima on its own and splits it 5 ways. I think what you're suggesting is to use a for loop outside of the N=3000 loop, which is a good idea in theory, but experience has shown that this will not generate 5 separate arrays. It will actually concatenate each array into one, hence the problem we currently have.
    Yik--I won't have access to Labview over the weekend. Is it possible to take a screenshot and post it, or maybe a short description?
    Thank you for the responses.

  • Custom for loop tag

    Hi all,
    I am trying to implement a custom "for loop tag". But it seems to me that there is a type conversion problem. I've tried many ways to fixed it but I still cannot get it to work. I've dug through my books, searched the internet and this forum but I can't found anythig useful. I am really lost now! Can anyone help me with this? Many many many thanks!!
    loopTag.jsp
    <%@ taglib prefix="myTag" uri="/WEB-INF/myTag.tld" %>
    <% int num=5; %>
    <myTag:loop index="i" count="<%=num%>">
         body1here: i expr: <%=i%> i property: <jsp:getProperty name="i" property="value"/> <br>
    </myTag:loop>
    myTag.tld
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>simple</shortname>
      <tag>
        <name>loop</name>
        <tagclass>myTag.LoopTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>for loop</info>
        <attribute>
            <name>index</name>
            <required>true</required>
        </attribute>
        <attribute>
            <name>count</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
      </tag>
    </taglib>
    LoopTag.java
    package myTag;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.util.Hashtable;
    import java.io.Writer;
    import java.io.IOException;
    public class LoopTag extends BodyTagSupport {   
        String index;
        int count;
        int i=0;
        public void setIndex(String index){
          this.index=index;
        public void setCount(String count){
          this.count=Integer.parseInt(count);
        public int doStartTag() throws JspException {
            return EVAL_BODY_TAG;
        public void doInitBody() throws JspException {
            pageContext.setAttribute(index, i);
            i++;
        public int doAfterBody() throws JspException {
            try {
                if (i >= count) {
                   bodyContent.writeOut(bodyContent.getEnclosingWriter());
                    return SKIP_BODY;
                                  else{
                                       pageContext.setAttribute(index, i);
                                  i++;
                return EVAL_BODY_TAG;
                        catch (IOException ex) {
                throw new JspTagException(ex.toString());
    Error message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 4 in the jsp file: /loopTag.jsp
    Generated servlet error:
    The method setCount(String) in the type LoopTag is not applicable for the arguments (int)
    An error occurred at line: 5 in the jsp file: /loopTag.jsp
    Generated servlet error:
    i cannot be resolved
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.11 logs.

    I took the custom for-loop one step further and now it can be nested with in other for-loop.
    Hope this is the last time I have to reinvent the wheel. Now I REALLY apprecate JSTL!!
    loopTag.jsp
    <%@ taglib prefix="myTag" uri="/WEB-INF/myTag.tld" %>
    <% int row = 5; %>
    <% int col = 5; %>
    <table border=0>
         <myTag:loop index="i" count="<%= row %>">
              <tr>
                   <myTag:loop index="j" count="<%= col %>">
                        <td>index: i=<myTag:printIndex parentLevel="2" /> j=<myTag:printIndex parentLevel="1" />, <br></td>
                   </myTag:loop>
              </tr>
         </myTag:loop>
    </table>
    myTag.tld
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>simple</shortname>
      <tag>
        <name>loop</name>
        <tagclass>myTag.LoopTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>for loop</info>
        <attribute>
            <name>index</name>
            <required>true</required>
                        <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>count</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
      </tag>
      <tag>
        <name>printIndex</name>
        <tagclass>myTag.LoopPrintTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>for loop print</info>
              <attribute>
            <name>parentLevel</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
      </tag>
    </taglib>
    LoopTag.java
    package myTag;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.util.Hashtable;
    import java.io.Writer;
    import java.io.IOException;
    public class LoopTag extends BodyTagSupport {   
        String index;
        int count;
        int i=0;
        public void setIndex(String index){
          this.index=index;
        public String getIndex(){
          return String.valueOf(pageContext.getAttribute(index));
        public void setCount(int count){
          this.count=count;
        public int doStartTag() throws JspException {
                         i = 0;
            return EVAL_BODY_TAG;
        public void doInitBody() throws JspException {
            pageContext.setAttribute(index, i);
            i++;
        public int doAfterBody() throws JspException {
            try {
                if (i >= count) {
                   bodyContent.writeOut(bodyContent.getEnclosingWriter());
                    return SKIP_BODY;
                                  else{
                                       pageContext.setAttribute(index, i);
                                  i++;
                return EVAL_BODY_TAG;
                        catch (IOException ex) {
                throw new JspTagException(ex.toString());
    LoopPrintTag.java
    package myTag;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.io.*;
    import javax.servlet.*;
    public class LoopPrintTag extends BodyTagSupport {
         private int parentLevel = 1;
      public int doStartTag() throws JspTagException {
              LoopTag parent = (LoopTag)findAncestorWithClass(this, LoopTag.class);
              for(int i=1; i<parentLevel; i++){
                   parent = (LoopTag)findAncestorWithClass(parent, LoopTag.class);
        if (parent == null) {
          throw new JspTagException("print not inside loop");
              else{
                   try {
                             JspWriter out = pageContext.getOut();
                             out.print(parent.getIndex());
                   } catch(IOException ioe) {
                             System.out.println("Error in printTag: " + ioe);
        return(SKIP_BODY);
         public void setParentLevel(int _parentLevel){
              if(_parentLevel > 0){
                   parentLevel = _parentLevel;
    Output:
    index: i=0 j=0, index: i=0 j=1, index: i=0 j=2, index: i=0 j=3, index: i=0 j=4,
    index: i=1 j=0, index: i=1 j=1, index: i=1 j=2, index: i=1 j=3, index: i=1 j=4,
    index: i=2 j=0, index: i=2 j=1, index: i=2 j=2, index: i=2 j=3, index: i=2 j=4,
    index: i=3 j=0, index: i=3 j=1, index: i=3 j=2, index: i=3 j=3, index: i=3 j=4,
    index: i=4 j=0, index: i=4 j=1, index: i=4 j=2, index: i=4 j=3, index: i=4 j=4,

  • How can I repeat a for loop, once it's terms has been fulfilled???

    Well.. I've posted 2 different exceptions about this game today, but I managed to fix them all by myself, but now I'm facing another problem, which is NOT an error, but just a regular question.. HOW CAN I REPEAT A FOR LOOP ONCE IT HAS FULFILLED IT'S TERMS OF RUNNING?!
    I've been trying many different things, AND, the 'continue' statement too, and I honestly think that what it takes IS a continue statement, BUT I don't know how to use it so that it does what I want it too.. -.-'
    Anyway.. Enought chit-chat. I have a nice functional game running that maximum allows 3 apples in the air in the same time.. But now my question is: How can I make it create 3 more appels once the 3 first onces has either been catched or fallen out the screen..?
    Here's my COMPLETE sourcecode, so if you know just a little bit of Java you should be able to figure it out, and hopefully you'll be able to tell me what to do now, to make it repeat my for loop:
    Main.java:
    import java.applet.*;
    import java.awt.*;
    @SuppressWarnings("serial")
    public class Main extends Applet implements Runnable
         private Image buffering_image;
         private Graphics buffering_graphics;
         private int max_apples = 3;
         private int score = 0;
         private GameObject player;
         private GameObject[] apple = new GameObject[max_apples];
         private boolean move_left = false;
         private boolean move_right = false;
        public void init()
            load_content();
            setBackground(Color.BLACK);
         public void run()
              while(true)
                   if(move_left)
                        player.player_x -= player.movement_speed;
                   else if(move_right)
                        player.player_x += player.movement_speed;
                   for(int i = 0; i < max_apples; i++)
                       apple.apple_y += apple[i].falling_speed;
                   repaint();
                   prevent();
                   collision();
              try
              Thread.sleep(20);
              catch(InterruptedException ie)
              System.out.println(ie);
         private void prevent()
              if(player.player_x <= 0)
              player.player_x = 0;     
              else if(player.player_x >= 925)
              player.player_x = 925;     
         private void load_content()
         MediaTracker media = new MediaTracker(this);
         player = new GameObject(getImage(getCodeBase(), "Sprites/player.gif"));
         media.addImage(player.sprite, 0);
         for(int i = 0; i < max_apples; i++)
         apple[i] = new GameObject(getImage(getCodeBase(), "Sprites/apple.jpg"));
         try
         media.waitForAll();     
         catch(Exception e)
              System.out.println(e);
         public boolean collision()
              for(int i = 0; i < max_apples; i++)
              Rectangle apple_rect = new Rectangle(apple[i].apple_x, apple[i].apple_y,
    apple[i].sprite.getWidth(this),
    apple[i].sprite.getHeight(this));
              Rectangle player_rect = new Rectangle(player.player_x, player.player_y,
    player.sprite.getWidth(this),
    player.sprite.getHeight(this));
              if(apple_rect.intersects(player_rect))
                   if(apple[i].alive)
                   score++;
                   apple[i].alive = false;
                   if(!apple[i].alive)
                   apple[i].alive = false;     
         return true;
    public void update(Graphics g)
    if(buffering_image == null)
    buffering_image = createImage(getSize().width, getSize().height);
    buffering_graphics = buffering_image.getGraphics();
    buffering_graphics.setColor(getBackground());
    buffering_graphics.fillRect(0, 0, getSize().width, getSize().height);
    buffering_graphics.setColor(getForeground());
    paint(buffering_graphics);
    g.drawImage(buffering_image, 0, 0, this);
    public boolean keyDown(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = true;
    else if(i == 1007)
         move_right = true;
              return true;     
    public boolean keyUp(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = false;
    else if(i == 1007)
         move_right = false;
    return true;
    public void paint(Graphics g)
    g.drawImage(player.sprite, player.player_x, player.player_y, this);
    for(int i = 0; i < max_apples; i++)
         if(apple[i].alive)
              g.drawImage(apple[i].sprite, apple[i].apple_x, apple[i].apple_y, this);
    g.setColor(Color.RED);
    g.drawString("Score: " + score, 425, 100);
    public void start()
    Thread thread = new Thread(this);
    thread.start();
    @SuppressWarnings("deprecation")
         public void stop()
         Thread thread = new Thread(this);
    thread.stop();
    GameObject.java:import java.awt.*;
    import java.util.*;
    public class GameObject
    public Image sprite;
    public Random random = new Random();
    public int player_x;
    public int player_y;
    public int movement_speed = 15;
    public int falling_speed;
    public int apple_x;
    public int apple_y;
    public boolean alive;
    public GameObject(Image loaded_image)
         player_x = 425;
         player_y = 725;
         sprite = loaded_image;
         falling_speed = random.nextInt(10) + 1;
         apple_x = random.nextInt(920) + 1;
         apple_y = random.nextInt(100) + 1;
         alive = true;
    And now all I need is you to answer my question! =)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    package forums;
    import java.util.Random;
    import javax.swing.Timer;
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class VimsiesRetardedAppleGamePanel extends JPanel implements KeyListener
      private static final long serialVersionUID = 1L;
      private static final int WIDTH = 800;
      private static final int HEIGHT = 600;
      private static final int MAX_APPLES = 3;
      private static final Random RANDOM = new Random();
      private int score = 0;
      private Player player;
      private Apple[] apples = new Apple[MAX_APPLES];
      private boolean moveLeft = false;
      private boolean moveRight = false;
      abstract class Sprite
        public final Image image;
        public int x;
        public int y;
        public boolean isAlive = true;
        public Sprite(String imageFilename, int x, int y) {
          try {
            this.image = ImageIO.read(new File(imageFilename));
          } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("Bailing out: Can't load images!");
          this.x = x;
          this.y = y;
          this.isAlive = true;
        public Rectangle getRectangle() {
          return new Rectangle(x, y, image.getWidth(null), image.getHeight(null));
      class Player extends Sprite
        public static final int SPEED = 15;
        public Player() {
          super("C:/Java/home/src/images/player.jpg", WIDTH/2, 0);
          y = HEIGHT-image.getHeight(null)-30;
      class Apple extends Sprite
        public int fallingSpeed;
        public Apple() {
          super("C:/Java/home/src/images/apple.jpg", 0, 0);
          reset();
        public void reset() {
          this.x = RANDOM.nextInt(WIDTH-image.getWidth(null));
          this.y = RANDOM.nextInt(300);
          this.fallingSpeed = RANDOM.nextInt(8) + 3;
          this.isAlive = true;
      private final Timer timer = new Timer(200,
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            repaint();
      public VimsiesRetardedAppleGamePanel() {
        this.player = new Player();
        for(int i=0; i<MAX_APPLES; i++) {
          apples[i] = new Apple();
        setBackground(Color.BLACK);
        setFocusable(true); // required to generate key listener events.
        addKeyListener(this);
        timer.setInitialDelay(1000);
        timer.start();
      public void keyPressed(KeyEvent e)  {
        if (e.getKeyCode() == e.VK_LEFT) {
          moveLeft = true;
          moveRight = false;
        } else if (e.getKeyCode() == e.VK_RIGHT) {
          moveRight = true;
          moveLeft = false;
      public void keyReleased(KeyEvent e) {
        moveRight = false;
        moveLeft = false;
      public void keyTyped(KeyEvent e) {
        // do nothing
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        //System.err.println("DEBUG: moveLeft="+moveLeft+", moveRight="+moveRight);
        if ( moveLeft ) {
          player.x -= player.SPEED;
          if (player.x < 0) {
            player.x = 0;
        } else if ( moveRight ) {
          player.x += player.SPEED;
          if (player.x > getWidth()) {
            player.x = getWidth();
        //System.err.println("DEBUG: player.x="+player.x);
        Rectangle playerRect = player.getRectangle();
        for ( Apple apple : apples ) {
          apple.y += apple.fallingSpeed;
          Rectangle appleRect = apple.getRectangle();
          if ( appleRect.intersects(playerRect) ) {
            if ( apple.isAlive ) {
              score++;
              apple.isAlive = false;
        g.drawImage(player.image, player.x, player.y, this);
        for( Apple apple : apples ) {
          if ( apple.isAlive ) {
            g.drawImage(apple.image, apple.x, apple.y, this);
        g.setColor(Color.RED);
        g.drawString("Score: " + score, WIDTH/2-30, 10);
      private static void createAndShowGUI() {
        JFrame frame = new JFrame("Vimsies Retarded Apple Game");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new VimsiesRetardedAppleGamePanel());
        frame.pack();
        frame.setSize(WIDTH, HEIGHT);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              createAndShowGUI();
    }Hey Vimsie, try resetting a dead apple and see what happens.

  • Getting the label of a JButton in a for loop

    hi,
    I doing a project for my course at the minute and im in need of a bit of help. I have set up 1-d array of buttons and i have layed them out using a for loop. I have also added an annoymous action listener to each button in the loop. It looks something lke this:
    b = new JButton[43];
    for (int i=1; i<43; i++)
    b[i] = new JButton(" ");
    b.addActionListener(
    new ActionListener()
    public void actionPerformed(ActionEvent e)
              System.out.println("..........");
    }); // addActionListener
    } // for
    I want the "System.out.println( ..." line, to print out the "i" number of the button that was pressed but i cannot figure out how to do it. I cannot put "System.out.println(" "+i);" as it wont recognise i as it is not inside the for loop. Does anyone have any suggestions?
    Thanks!!

    class ButtonExample extends JFrame implements ActionListener{The OP wanted to have anonymous listeners, not a subclassed JFrame
    listening to the buttons. I don't know if the following is the best design,
    since the poster has revealed so little, but here is how to pass the
    loop index to an anonymous class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ButtonExample {
        private JButton[] buttons = new JButton[24];
        public JPanel createGUI() {
            JPanel gui = new JPanel(new GridLayout(6,  4));
            for(int i=0; i<buttons.length; i++) {
                final int ii = i; //!! !
                buttons[i] = new JButton("button #" + i);
                buttons.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent evt) {
    System.out.println("number " + ii);
    gui.add(buttons[i]);
    return gui;
    public static void main(String[] args) {
    ButtonExample app = new ButtonExample();
    JPanel gui = app.createGUI();
    JFrame f = new JFrame("ButtonExample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(gui);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);

  • How to pass the sequence number of current loop in a for loop in FPGA vi to the host

    PCI-7830R
    LV 8.2
    What I was trying to do is to use multiple DIO to generate pulse at different sequence. Mode one is to automatically sweep from DIO1 to DIO20; mode 2 is several DIOs generate pulse simoutaneously.  So I use a case structure to make the selection, in the mean time, I set up two for loop in each case so that I can use multiple pulse generations. For example, in scanning mode, if I set 2 exposures, it sweeps from 1 to 20 then do it again.  
    Then I need to get the loop sequence number, i of each scenario. So I put an indicator within the first loop, and create a local variable of it and put in the second one.  Running the FPGA vi alone, I can see the indicator change in each case from 0 to N-1, N being the for loop time.But in the host vi, I tried to add this indicator as an element in the read/write invoke method, in the debugging mode, I could only see it directly jump to N-1 without all the changes I saw in FPGA vi. 
    Is it possible to get this number passed correctly from FPGA vi to the host vi? Thanks

    Thanks for the reply Jared.
    Excuse me if it looks incorrect, but I'm new to FPGA programming, so I would have to look into the FIFO you referred to.  I used local variables because for one thing I have several different cases containing for loop in each of them, and I only want one indicator for the "i".  If I put the indicator out of any for loop, it's only gonna show the last number which is N-1.  For the other thing, it seems like property nodes are not allowed in FPGA vi.  And by doing this, I can see the i number changing from 0 to N-1 in each case, well, in FPGA vi's front panel.  But while I ran the host vi with everything, the indicator in host vi's front panel only showed the last number N-1. It may be the reason you said, it happened too fast before the indicator in host vi can catch it.
    What I want to realize is to group the data I collect in host vi, for example, when I choose multiple exposure in each mode, and the FPGA runs 1 through 20 then do it again, I want the data stored in two groups using the loop sequence number as the seperator in file name.  So it goes like 1-1, 2-1.......20-1; then 1-2, 2-2,.....20-2.

  • How do we use if statement in labview?moreover can i use if statement inside for loop?

    how do we use if statement in labview?moreover can i use if statement inside for loop?

    The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
    Attachments:
    For_Loop_with_Case.jpg ‏21 KB

  • Select statement in a for loop

    Hi all,
    Can a select stmt be used in the body of the for loop/ nested for loop ?
    I tries using (even if its very simple for loop) it gives the following error
    PL/SQL: ORA-00933: SQL command not properly ended...
    code is
    DECLARE
    CURSOR C1 is select 'Monday'  from dual
    union all
    select 'Tuesday' from dual
    union all
    select 'Wednesday' from dual
    union all
    select 'Thursday' from dual
    union all
    select 'Friday' from dual
    union all
    select 'Saturday' from dual
    union all
    select 'Sunday' from dual;
            type rec_info is record
            name varchar2(20),
            FNAME varchar2(20),
            LNAME varchar2(20)
            type ty_info is table of rec_info;
            info ty_info;
            type rec_abc is record
            day varchar2(3000)
            type ty_abc is table of rec_abc;
            abc ty_abc;
            Cursor C2 is
            select t.name, u.first_name, u.last_name
            from territories t, users u, territories_users tu
            where t.ID = tu.TERRITORY_ID
            and tu.USER_ID = u.ID ;
    BEGIN
    OPEN C1;
    Loop
    FETCH C1 into abc;
    EXIT when C1%notfound;
    DBMS_OUTPUT.PUT_LINE(abc);
    END LOOP;
    CLOSE C1;
    OPEN C2;
    FETCH C2 BULK COLLECT into info;
    CLOSE C2;
           for i in info.first .. info.last
           LOOP
                       for j in abc.first .. abc.last
                       LOOP
                              select --info(i).name, info(i).FNAME, info(i),LNAME,'AM' "AM/PM",
                            to_char(c.name)||' '||ct.PRIMARY_ADDRESS_CITY||','||ct.PRIMARY_ADDRESS_STATE||','||ct.PRIMARY_ADDRESS_COUNTRY
                           from
                            territories t, territories_users tu,
                            users u, calls_users cu, calls c, 
                            calls_contacts cc, contacts ct    
                            where
                            tu.TERRITORY_ID = t.id
                            and t.name = info(i).name
                            and u.first_name = info(i).FNAME
                            and u.last_name = info(i).LNAME
                          and (c.date_start between trim(next_day(sysdate,abc(j).day)) and trim(next_day(sysdate,abc(j).day)))
                            and tu.USER_ID = u.id
                            and cu.USER_ID = u.id
                            and cu.CALL_ID = c.id
                            and to_char(c.time_start,'hh24') < '12'
                            and cc.CALL_ID = c.ID
                            and cc.CONTACT_ID = ct.id
                            and rownum < 2
                     END LOOP;
         END LOOP;
    END;

    "Can a select stmt be used in the body of the for loop/ nested for loop "
    Yes.... but with an INTO part.....
    select c1 , c2 , c3 into var1 , var2 , var3 from table1
    Sim

  • If statement doesn't affect for loop

    I wrote a function within a function to control 2 Tweens.
    (the 2nd one isnt in the function, it's called)
    My problem is... is that it works for the first time.. the button is hovered over and all the other buttons show themselves and then disappear again, except the one you're over. Then I do it a 2nd time and it doesn't work. why is it only working right one time? and why isn't the if statement I put in the local function affecting the for loop? The 2nd time it takes the button you're hovering over with it and fades it out. (even though the if statement registers according to trace)
    this is the code
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    var shortInst:Array = [btn1, btn2, btn3, exit];
    var objTween:Tween;
    function mouseOff(e:Event):void {
         if (e.currentTarget.alpha !== 0) {
              objTween = new Tween(e.currentTarget, "alpha", None.easeOut, 1, 0, 0.25, true);
    var eTimer:Timer = new Timer(3000, 1); //timer that only runs once (in ms)
    function navFX(e:Event):void {
         for (var i:Number = 0; i < shortInst.length; i++) {
              objTween = new Tween(shortInst[i], "alpha", None.easeOut, 0, 1, 0.25, true);
              eTimer.addEventListener(TimerEvent.TIMER, local);
              eTimer.start();
              function local(t:TimerEvent):void {
                   trace("e.target in local func: " + e.target);
                   for (var i:Number = 0; i < shortInst.length; i++) {
                        if (shortInst[i] !== e.target) {
                        shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));

    is this what you want?
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    var shortInst:Array = [btn1,btn2,btn3,exit];
    var objTween:Tween;
    function mouseOff(e:Event):void
    if (e.currentTarget.alpha !== 0)
      objTween = new Tween(e.currentTarget,"alpha",None.easeOut,1,0,0.25,true);
    function navFX(e:Event):void
    var eTimer:Timer = new Timer(3000,1); // <- moved that line here
    for (var i:Number = 0; i < shortInst.length; i++)
      objTween = new Tween(shortInst[i],"alpha",None.easeOut,0,1,0.25,true);
    eTimer.addEventListener(TimerEvent.TIMER, local);
    eTimer.start();
    function local(t:TimerEvent):void
      trace("e.target in local func: " + e.target);
      for (var i:Number = 0; i < shortInst.length; i++)
       if (shortInst[i] !== e.target)
        shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));
    for (var i:Number = 0; i < shortInst.length; i++)
    shortInst[i].alpha = 0;
    shortInst[i].addEventListener(MouseEvent.MOUSE_OVER, navFX);
    shortInst[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOff);

  • Help with Mathscipt and for loop

    I have a code in Mathscript/matlab and I need to output the array out. One option is my first code,the other option is using a for loop, but I am only getting the last ouput out. I need to get the whole output out.
    Any help.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Help with Mathscript_for loop.vi ‏115 KB
    Help with Mathscript_for loop2.vi ‏84 KB

    Here's how it should look like.
    Message Edited by altenbach on 10-30-2008 05:12 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    MathscriptInFOR.png ‏15 KB

Maybe you are looking for

  • How to connect WAG54G ver. 1.2, to a WRT54G2?

    Is it possible to use the modems 4 lan ports and the routers 4 ports as well? Which one has the best WiFi connections? Can I use both, if so, how? I'm a noob at this things....

  • Can we erase .dmg files once the program has been installed?

    Are the Disk Images and the .dmg files necessary to keep on your computer once you've installed the software? I mean does the program (any) have to access this 'placenta' in order to do it's job/ get more information? Is it continually exchanging dat

  • HT201250 Need to free up space!

    I have an external drive, it's hooked up and everything. Can I now delete files taking up massive amounts of space and get them back later down the line? The reason for this is that my drive is taken up by 105 GB of "other" and I cannot identify what

  • JComboBox items not showing up properly ?

    I have the following program : import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class Java_Test extends JPanel   static JTabbedPane Tabbed_Pane=new JTabbedPane();   JComboBox Contacts_ComboBox;   Customer_I

  • My skype got deleted?

    Dear folks, yesterday I was logged on my skype and talked with people like normal. I was eating, and when I came back, I was logged off... I tried to log in, but I couldn't log in. It says wrong username/pw, even though I'm pretty sure its the correc