Help with  looping logic

1. I am new to this forum, can someone let me know how I attach a code tag.
2. Im doing an exercise where I have to enter 20 values into an array . Each value I enter has to be different from a value previously entered value.If the value already exists in the array, the program should allow the user to put in a another value. I have been trying nested for loops but im just confused. Can someone help me on how to go about it ?

1. I am new to this forum, can someone let me know
how I attach a code tag.http://forum.java.sun.com/help.jspa?sec=formatting
2. Im doing an exercise where I have to enter 20
values into an array . Each value I enter has to be
different from a value previously entered value.If
the value already exists in the array, the program
should allow the user to put in a another value. I
have been trying nested for loops but im just
confused. Can someone help me on how to go about it ?for (loop twenty times)
ask user for value
while (value is in the array) ask user for new value
insert value into array
next

Similar Messages

  • Problem with looping logic

    Hello all,
    Ok reposted using code tags, sorry about that.
    I'm trying to write some code to take in a 2D int array, loop through the array to identify where certain blocks of numbers begin and record that location so that I an jump straight to it at a later time. The number blocks go up iteratively from a point from 0 to 9 and are surrounded by nodata values(-9999).
    The problem is that when I print out the numbers they are only being recognised up to 6 (7th number) and when I check the locations against the original text file they dont match. I think it's just a problem with my logic but I'm not sure why.
    The text file is converted to ints and placed in an array from a buffered file reader in a seperate class. I can put this up if needed.
    Any help would be much appreciated.
    Thanks.
    Duncan
    *  Class imports text file which contains a collection of values, either nodata(-9999) or a location
    *  represented by numbers moving away from a point; 0 closest then 1, then 2 etc.
    *  records the first location of each number to avoid having to loop through the whole file each time.
    *  i.e. can later jump straight to the first recorded location of each number.
    *  In current text file there are 10 numbers(0 - 9) but for some reason it stops finding them after
    *  6(seventh no.) and having checked the location values against the original text file these are wrong
    *  by a fair way as well.
    import java.io.*;
    //import java.awt.*;
    //import java.awt.event.*;
    public class Hydrograph {
         int width = 0;
         int height = 0;
         int dZeroC, dZeroD = 0;
         int dOneC, dOneD = 0;
         int dTwoC, dTwoD = 0;
         int dThreeC, dThreeD = 0;
         int dFourC, dFourD = 0;
         int dFiveC, dFiveD = 0;
         int dSixC, dSixD = 0;
         int dSevenC, dSevenD = 0;
         int dEightC, dEightD = 0;
         int dNineC, dNineD = 0;
         public Hydrograph() {
              /* Ignore this bit it's being used for something else
              //File file = new File("c:/Users/Duncan/Documents/MODULES/MSc Dissertation/Code/A1.txt");
              //File file = new File("M:/java/code/A1.txt");
              ArrayRead ar = null;
              ar = new ArrayRead(file);
              int rows = ar.getRows();
              int columns = ar.getColumns();
              int steps = ar.getSteps();
              int[][][] threeDIntArray = ar.getThreeDIntArray();
              // Creates a new instance of delay class which takes in a text file and converts
              // it to int form, placing it into a 2D int array.
              Delay dLay = null;
              dLay = new Delay();
              width = dLay.getWidth();
              height = dLay.getHeight();
              int[][] twoDDelayFile = dLay.getTwoDintArray();
              int delayCount = 0;
              // Loops through 2D int array to identify when number first equals 0, then passes
              // the height and width values to storeDelayPos method below. Then finds for 1, 2
              // 3, 4,...etc by adding 1 to delayCount.
              System.out.println(" ");
              for (int a=0; a<width; a++) {
                   for (int b=0; b<height; b++) {
                        if (twoDDelayFile[a] == delayCount) {
                             int c, d = 0;
                             c = a;
                             d = b;
                             storeDelayPos(c, d, delayCount);
                             System.out.println(delayCount);
                             delayCount++;
                             break;
                   //System.out.println(" ");
              System.out.println(" ");
              System.out.print(dZeroC + " " + dZeroD);
              System.out.println(" ");
              System.out.print(dOneC + " " + dOneD);
              System.out.println(" ");
              System.out.print(dTwoC + " " + dTwoD);
              System.out.println(" ");
              System.out.print(dThreeC + " " + dThreeD);
              System.out.println(" ");
              System.out.print(dFourC + " " + dFourD);
              System.out.println(" ");
              System.out.print(dFiveC + " " + dFiveD);
              System.out.println(" ");
              System.out.print(dSixC + " " + dSixD);
              System.out.println(" ");
              System.out.print(dSevenC + " " + dSevenD);
         // Takes in width, height and delayCount value and sets variables according to
         // the value of delayCount.
         void storeDelayPos (int setC, int setD, int setDCount) {
              int dCount = 0;
              dCount = setDCount;
              switch(dCount) {
                   case 0:
                        dZeroC = setC;
                        dZeroD = setD;
                        break;
                   case 1:
                        dOneC = setC;
                        dOneD = setD;
                        break;
                   case 2:
                        dTwoC = setC;
                        dTwoD = setD;
                        break;
                   case 3:
                        dThreeC = setC;
                        dThreeD = setD;
                        break;
                   case 4:
                        dFourC = setC;
                        dFourD = setD;
                        break;
                   case 5:
                        dFiveC = setC;
                        dFiveD = setD;
                        break;
                   case 6:
                        dSixC = setC;
                        dSixD = setD;
                        break;
                   case 7:
                        dSevenC = setC;
                        dSevenD = setD;
                        break;
                   case 8:
                        dEightC = setC;
                        dEightD = setD;
                        break;
                   case 9:
                        dNineC = setC;
                        dNineD = setD;
                        break;
                   default:
                        System.out.println("OUT OF BOUNDS");
                        break;
         public static void main (String args[]) {
         new Hydrograph();

    Hi,
    I am working on a hydrograph program in java as well... I am trying to represent rainfall data. Do you think that you could share some of the code that you came up with, so that I don't have to go through the whole process.
    thank you so much,
    Kevin

  • Help with looping and counting

    i am in a CS 1 class and need help with this loop
    /*Write a program that will allow the user to enter a character
              until the capital letter Z is entered
         The program should count the number of letters entered
              and print the total after the loop is completed*/
    here is what i have it doesn't end nor does it count and i don't know hwo to make it count also i suck at do..while loops hehe
    char b,Z=0;
              Scanner a = new Scanner(System.in);
         do
                   System.out.print("Enter a letter: "+"\n");
                   b=a.next().charAt(0);
              while (b !=Z);
    i know that its not even close to being right just help me out here
    Edited by: purplesmurf on Nov 14, 2008 7:25 PM

    The following program will count the number of chacters entered until Z is enetered.
    import java.io.*;
    class count
         public static void main(String[] args)throws IOException
              char ch;
              int cnt=0;
              DataInputStream br=new DataInputStream(System.in);
              do
              System.out.print("Enter a character:");
              ch=(char)br.read();
              if(ch!='Z')
                   cnt++;
              else
                   break;
              }while((ch=(char)br.read())!='Z');
              System.out.println("The Number of entered characters are:"+cnt);
    }

  • Need a little help with RAF logic

    So Im making a program to give different users, different rights. This is the method that appends them to file and Map
         * Writes the players rights to the appendages
         * @param playerName Player to update
         * @param playerRights Rights to give the player
         * @param pointer The lines index in the files
         * @throws IOException If a read/write error occours
        public void writeRights(String playerName, Rights playerRights, long pointer) throws IOException {
            rightsRAF.seek(pointer);
            rightsRAF.write(("\n" + playerName + "::" + playerRights).getBytes());
            if(rightsRAF.read() != '\n') {
                rightsRAF.seek(rightsRAF.getFilePointer()-1);
                rightsRAF.write("\n".getBytes());
            rightsMap.put(playerName, playerRights);
        }1. The RAF goes to the predetermined index in the file, pointer, which is the line the users name starts on. Entries are stored in the file as "name::RIGHTS"
    2.It writes out the players name, and rights
    3. It checks to see if it accidentally wrote over the \n
    My problem now, is that some rights are longer than others. For example, if there was already an entry, "name::MODERATOR" and you overwrite it, with "name::OWNER" then it would turn into "name::OWNERATOR" because the rest of the line wasn't overwritten.
    I need some help with logic to determine how to overwrote the entire line, because sometimes you could go from a short one, to a long one, and need to append a new \n character, and sometimes you could go the other way around from long to short and end up with two words fused, I cant figure out how to determine whats a word that got partially overwritten and whats a new line totally.
    Thanks

    As pointed out you need to have fixed size records, or at least a maximum size.
    You also have another problem nobody commented on yet (I don't think) with the getBytes() calls. At that point in your code you will mangle most unicode Strings.
    All things being equal here I think your best solution is to use an embedded database like JavaDB with JDBC. I think you will find an XML solution to slow for your purposes.
    If you decide to continue the RAF route though here is an example. I know this is not exactly what you are doing but you can extrapolate from this...
    public void updatePlayerName(String playerName, int playerIndex){
       int recordlength = 200;  
       byte[] buff = playerName.getBytes("UTF-8");
       if(buff.length>recordlength){
          //truncate bytes. this is also not great because a character at the end could be mangled
          byte[] temp = new byte[recordlength];
          System.arraycopy(buff,0,temp,0,temp.length);
          buff = temp;
       long pointer = playerIndex * (recordlength+4);// plus 4 bytes per record for actual length
       raf.seek(pointer);
       raf.writeInt(buff.length);
       raf.write(buff);
    public String getPlayerName(int playerindex){
        int recordlength = 200;  
        long pointer = playerIndex * (recordlength+4);
        raf.seek(pointer);
        int lengthToRead = raf.readInt();
        //length to read should be checked for sanity or bad things will happen next
        byte[] buff = new byte[lengthToRead];
        raf. readFully(buff);
        return new String(buff,"UTF-8");
    }And then of course you'd have to add storing the "rights". It gets complicated in a hurry. I do really recommend the JDBC route.

  • I need Help with loop

    Hello everyone this is my first time posting here, i have always find java easy(up to this point), this is my first class in programming java i am just needing help with the "for loops" i cant seem to get the program generate 10 random math questions. if you guys can please help i will appreciate it, i have been working on it for a couple of hours. I am not finished with it yet but thats the only thing i need help with.
    import javax.swing.JOptionPane;
    public class Lab5
    public static void main(String[] args)
    int num1 = (int) (Math.random() * 100 + 1);
    int num2 = (int) (Math.random() * 100 + 1);
    int sum = num1 + num2;
    int product = num1 * num2;
    int quotient = num1 / num2;
    int difference = num1 - num2;
    for (int i = 0; i > 11; i++);
    int number = (int)(Math.random()*4);
    if (number == 0 )
    String s1 = JOptionPane.showInputDialog(null, num1 + " + " + num2 + "=" );
    if(number == 1)
    String s3 = JOptionPane.showInputDialog(null, num1 + " - " + num2 + "=" );
    if(number == 2)
    String s3 = JOptionPane.showInputDialog(null, num1 + " x " + num2 + "=" );
    if(number == 3)
    String s4 = JOptionPane.showInputDialog(null, num1 + " &divide; " + num2 + "=" );

    for (int i = 0; i > 11; i++);Two problems with this line:
    1) The second part of a For loop is the constraint. You have said that for the loop to be entered, i must be greater than 11. Well since you've also told i to begin at 0, this will never happen. Thus, the loop will never enter. You may have meant less than?
    2) You put a semicolon in the line. Semicolons are used to end statements. The For loop, when used as a block with curly braces, is not a single statement and does not require a semicolon. Here's the two structures of a basic For loop:
    for(int i = 0; i <= 100; i++) {
        //this is a block. you can put multiple statements in here and they are all part of the loop
        int a = 1;
        int b = i;
    //if your loop only needs to use a single statement, no braces are required
    for(int i = 0; i <= 100; i++)
        int a = i;

  • Help with pnpce logic data base

    Hallow I doing a program that use logic data base pnpce(my first time) and in the program I use get peras to bring the employee num and in the loop the name of employee
    Something I doing wrong because its not working what?
    I just wont to bring to my table person_tab employee num and name.
    thankes
    Tables :pernr
    Nodes:persa
    Infotypes:0000 like t_oooo,
    00002 like t_0002.
    START-OF-SELECTION.
    GET peras.
    LOOP AT t_0000.
    MOVE t_0000-pernr TO person_tab-objid.
    APPEND person_tab.
    Endloop.
    Loop at t0002.
    MOVE t_0002-nachn TO person_tab-lastname.
    MOVE t_0002-vorna TO person_tab-firstname.
    APPEND person_tab.
    ENDLOOP.
    END-OF-SELECTION.

    Hi there. I'm not sure what version you are on, but in ERP 2005 this is an obsolete statement.  Here's an alternate way to get the information you're looking for:
    TABLES: PERNR.
    INFOTYPES: 0002.
    DATA: BEGIN OF person_tab OCCURS 0,
           objid LIKE PERNR-PERNR,
           lastname LIKE P0002-NACHN,
           firstname LIKE P0002-VORNA,
    END OF person_tab.
    START-OF-SELECTION.
    GET pernr.
    person_tab-objid = pernr-pernr.
    RP-PROVIDE-FROM-LAST P0002 space sy-datum sy-datum.
    person_tab-lastname = p0002-nachn.
    person_tab-firstname = p0002-vorna.
    APPEND person_tab.
    CLEAR person_tab.
    END-OF-SELECTION.
    Even if you don't end up using this code, you would need to change yours so that you aren't appending to your person_tab table until you have moved all of the data for the fields of your record. By appending twice like you currently are doing, you are creating two separate records (one with just the pernr and another with the first and last name).  I hope this helps.
    - April King

  • Help with Loop Function

    I am trying to automate converting Pages documents to Word. Maybe later to reopen them in Pages but with the options set to create flat files.
    I select the files I want and they open ok. The export goes ok and I click the file close button,
    Maybe this close does not work as I get twice as many files open after each loop.
    How do I stop the loop function bringing all the files in again each time.?
    Get Selected Items
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    Export
    Click the "Next..." button
    Click the "<fill the title>" button
    Loop (use the current results as input)
    Your help would be welcome!
    Message was edited by: putnik

    Thanks again,
    The "Dispense Items Incrementally" seems to work well enough. However, now the workflow stops at the end of the second loop. The file is closed but the "Watch Me" function seems to want something else to happen (it continues active). The only first file is still listed in the loop function.
    Get Selected Items
    Dispense Items Incrementally
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    "Export"
    Type '
    Type '
    <Cmd W>
    Loop (up to 10 times, use the current results as input)
    Note that I am learning to avoid mouse gestures where possible as things move about to much...
    Any idea what I need to do?

  • Help withe loop on tables

    Hallow in my table itab I have employee (sobid employee number and names ex. 80 emp) in my loop(b_itab) I get all he employee that doing the course (their sobid just 3 emp) how can I use b_itab to write to other table (d_itab) to write all the employee that don’t doing the course .I need a  general solution.
    <b>Ex.i have a table with 80 emp and I doing a loop on this table and find 3 employee that doing course how can I do  comparison in the 2 table that if the employee not in b_itab(emp doing course) write them in d_itab(oteer table).</b>    .if u need more details  please let me now.
    regards

    Loop at itab.
    Specify the condition here if they are doing the course
    if (Condition here)
    append itab to b_itab.
    else
    append itb to d_tab.
    endif.
    endloop.
    The other option will be:
    loop at itab.
    read table b_itab with key course = itab-course.
    if sy-subrc NE 0.
    append itab to d_itab.
    endif.
    endloop.
    Can you try these options? If not, please give the structure of the internal table to know exactly you want to do.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • Help with Jsp: logic:iterate  Cannot create iterator for this collection

    Hello,
    I am developing a jsp with struts. This is the snap of the code:
            <logic:iterate id="prod" collection="productList" >
              <tr align="center">
                   <td><html:text property="prodDesc" size="50" indexed="true"/></td>
                   <td>
                        <html:select property="prodUnit" indexed="true">
                             <option selected>-</option>
                            <OPTION VALUE='NMB'>NMB
                             <OPTION VALUE='TEN'>TEN
                             <OPTION VALUE='TPR'>TPR
                             <OPTION VALUE='GWH'>GWH
                        </html:select>
                   </td>
                   <td><html:text property="prodQty" size="20" indexed="true"/></td>
                   <td><html:text property="prodVal" size="20" indexed="true"/></td>               
              </tr>
            </logic:iterate>"productList" is defined as an array of Product[], "prod" is defined as a single Product object in the form. But when i run the page, it gives me this errors:
    "javax.servlet.jsp.JspException: Cannot create iterator for this collection".
    I also tried to make "productList" an ArrayList type, but it game me this same error.
    We are using Websphere 4.0 with Struts 1.1.
    Anyone can help?
    Thanks a lot.
    All the best,
    warren

    Hi , I have similar problem. wonder anyone can help me. I have a datastructure. ArrayList contains list of Hashtable; each Hashtable has two key-value sets ; for each key-value set , value is a ValueObject.
    My jsp works ok. but when I click on the radio butten for one radio group, it sets not only the porperty on that row, but the rows belows ,which suppose to be another radio group , because I am using indexed="true". each row should be a individual group seperated by the name poDisplayVO[i] , as show in the html generated .
    <!-- JSP -->
    <logic:iterate id="poDisplayVO"
    name="testForm"
    property="poDisplayVOList"
    type="java.util.Hashtable">
    <tr>
    <td>
    <bean:write name="poDisplayVO" property="name"/>
    </td>
    <td>          
    <% String val = ((java.util.Hashtable)poDisplayVO).get("subjAreaName").toString();%>
    <html:radio indexed="true" name="poDisplayVO" property="fosVO.select" value="<%=val %>" />
    <bean:write name="poDisplayVO" property="subjAreaName"/>
    </td>
    <td>           
    <html:radio indexed="true" name="poDisplayVO" property="fosVO.select" value="no" /> NO
    </td>
    <td>           
    <html:radio indexed="true" name="poDisplayVO" property="fosVO.select" value="yes" /> YES
    </td>
    </tr>
    </logic:iterate>
    <! ------------------------ html genterated ------------------------------------------------>
    the HTML generated as folllows:
    <tr>
    <td>
              Accounting Studies
    </td>
    <td>          
         <input type="radio" name="poDisplayVO[0].fosVO.select" value="Accounting">
              Accounting
    </td>
    <td>           
         <input type="radio" name="poDisplayVO[0].fosVO.select" value="no"> NO
    </td>
    <td>           
         <input type="radio" name="poDisplayVO[0].fosVO.select" value="yes"> YES
    </td>
    </tr>
    <tr>
    <td>
              Accounting Studies
    </td>
    <td>          
         <input type="radio" name="poDisplayVO[1].fosVO.select" value="Bookkeeping">
              Bookkeeping
    </td>
    <td>           
         <input type="radio" name="poDisplayVO[1].fosVO.select" value="no"> NO
    </td>
    <td>           
         <input type="radio" name="poDisplayVO[1].fosVO.select" value="yes"> YES
    </td>
    </tr>
    <tr>
    <td>
              Accounting Studies
    </td>
    <td>          
         <input type="radio" name="poDisplayVO[2].fosVO.select" value="Computerized Accounting(Duplicate)">
              Computerized Accounting(Duplicate)
    </td>
    <td>           
    <input type="radio" name="poDisplayVO[2].fosVO.select" value="no"> NO
    </td>
    <td>           
    <input type="radio" name="poDisplayVO[2].fosVO.select" value="yes"> YES
    </td>
    </tr>
    <! ------------------------ action form-----------------------------------------------
    public ArrayList getPoDisplayVOList() {
         return poDisplayVOList;
    public void setPoDisplayVOList(ArrayList list) {
         poDisplayVOList = list;
    public Hashtable getPoDisplayVO(int i) {
         Object obj = poDisplayVOList.get(i);
         if (obj == null)
              obj = new Hashtable();
              poDisplayVOList.add(obj);
         return (Hashtable)poDisplayVOList.get(i);
    public void setPoDisplayVO(Hashtable programDisplayVO, int i) {
              poDisplayVOList.add(i, programDisplayVO);
         }

  • Help with sql logic

    I have two tables some_table1 and some_table2
    desc some_table1
    Name Type
    ID NOT NULL VARCHAR2(16)
    NAME VARCHAR2(25)
    desc some_table2
    Name Type
    ID NOT NULL VARCHAR2(16)
    STATUS VARCHAR(20);
    The requirement is to concatenate INATIVE status value to ID with status = 'INACTIVE' in some_table2.
    eg if id in some_table1 and some_table2 = 1 and status in some_table2 = 'INACTIVE', I will have to append
    'INACTIVE' || some_table1 name, the question is some_table1 have a lots of names that the length is already 25
    characters, the requirement want Inative||' '||name inrespective of the name length, I am not allow to increase the name datatype length , but can reduce name to allow for the Inactive||' '||
    declare
    cursor c1 IS
    select cst1.id,cst1.name,cst2.status
    from some_table1 cst1, some_table2 cst2
    where cst1.orgid = cst2.orgid
    and cst2.status = 'INACTIVE';
    c1_data c1%rowTYpe;
    BEGIN
    OPEN c1;
    LOOP
    FETCH C INTO c1_data ;
    EXIT WHEN C1%NOTFOUND;
    UPDATE some_table1
    SET NAME = c1_data.status||' '|| c1_data.name
    where id = c1_data.id;
    END LOOP;
    CLOSE;
    END;
    ORA-12899: value too large for column "TEST"."ID"."NAME" (actual: 34, maximum: 25)
    I want to be able to fit the update in inrespctive of the name length, I need a logic to truncate the name so as not to exceed the maximum size.
    Thank you.

    I found the solution. sometable2.status||' '||substr(sometable1.name,1,25-9) since inactive with a space is 9 xters.
    Thank you everyone.
    Edited by: Ade2 on Feb 11, 2009 5:26 PM

  • Help with this logic

    Dear experts;
    I have two tables similar to this below
    create table t1
       place varchar(1000),
       start_time date,
        end_time date
    insert into t1 values ('NewYork', to_date('2013-01-01', 'YYYY-DD-MM'));
    create table t2
      date_list date,
      week_description varchar(1000)
    insert into t2 values (to_date('2013-01-01', 'YYYY-DD-MM'), 'week 1('2013-01-01' - '2013-02-01)')
    insert into t2 values (to_date('2013-02-01', 'YYYY-DD-MM'), 'week 1('2013-01-01' - '2013-02-01)')
    insert into t2 values (to_date('2013-03-01', 'YYYY-DD-MM'), 'week 2('2013-03-01' - '2013-04-01)')
    insert into t2 values (to_date('2013-04-01', 'YYYY-DD-MM'), 'week 2('2013-03-01' - '2013-04-01)')I would like a simple logic that will give me an opportunity to insert new values in my t1 table for a particular given week_description
    So take for instance, we have only one row right now in t1, which is NewYork, 2013-01-01
    I want a case where I can get week 2 information from t2, so that t1 will end up with the following result.
    NewYork, 2013-01-01
    NewYork, 2013-03-01
    NewYork, 2013-04-01
    Kindly note, the week 2 will always be a user input. All help is appreciated.
    Edited by: user13328581 on May 17, 2013 5:46 AM
    Edited by: user13328581 on May 17, 2013 5:46 AM

    user13328581 wrote:
    The place will always be gotten from t1 unfortunatelyHow?
    Does T1 always have only 1 place?
    ie
    select distinct place from T1??
    What happens when we add:
    insert into t1 values ( 'Boston', sysdate );??
    How do I derive the Place?

  • Need help with loop

    The script below analyses an indesign doc for missing links and then places library asset on the page, cuts and "pastes into" any frame with a missing link (the cut and paste thing sucks, but we can't figure out any other way to avoid an external image source for the missing pic placeholder graphic). The loop finds the missing links except for 2. If there are 5 missing links, it finds 3. If there are 10 missing links, it finds 8...etc. Why won't it catch them all?
    Script below:
    myCheckGraphics();
    function myCheckGraphics(){
             myDocument=app.activeDocument;
            for(var myCounter = 0; myCounter < myDocument.allGraphics.length; myCounter++){
                var myGraphic = myDocument.allGraphics[myCounter];
                if(myGraphic.itemLink.status == LinkStatus.LINK_MISSING){
                    var myLib=app.libraries.item("Missing Link.indl");
                if(File.fs == "Macintosh"){
                    var myLibPath=app.open(File("/Applications/Adobe Indesign CS3/Cover Setup/Missing Link.indl"));
                else{
                myLibPath=app.open(File("/c/Program%20Files/Adobe/Cover Setup/Missing Link.indl"));
                var selectMiss=app.select(myGraphic);   
                missLink=app.selection[0].parent;
                var selectBox=app.select(missLink);
                var myX=missLink.visibleBounds;
                var myTop=myX[0];
                var myLeft=myX[1];
                var myBottom=myX[2];
                var myRight=myX[3];
                var myWide=myRight-myLeft;
                var myBigBottom=myBottom-myTop;
                if((myWide>35)||(myBigBottom>20)){
                    myAss=myLib.assets.item("Missing Link Big");
                else if((myWide>15)||(myBigBottom>10)){
                    myAss=myLib.assets.item("Missing Link Medium");
                else{
                    myAss=myLib.assets.item("Missing Link Small");
                    myMissAlert();
                    }//end if missing link
                }//end for loop
        function myMissAlert(){
            ////place the asset.//////
            myAss.placeAsset (myDocument) ;
            var myAsset=myDocument.pageItems.item("Missing Link");
            var selectAss=app.select(myAsset);
            var myDupe = app.copy() ;
            var det=myAsset.remove();
            var selectBox=app.select(missLink);
            var myPaste=app.pasteInto()
            app.select(NothingEnum.nothing, undefined);

    A fairly recurrent "problem" with Indesign.
    The loop checks for missing links on an array of images. However, as soon as you correct one of these links, the array it's checking gets updated in the background, so the loop seems to skip every other image!
    Suppose you have an array
    missingLinks = [ "a", "b", "c" ]
    (where all are missing) and you loop from 0 to 2. The first one checks #0 and corrects it. Now the array will change (in the background) to
    ["b", "c"]
    ... and your loop happily continues with #1 -- "c".
    The common solution is to loop over the array backwards:
    for(var myCounter = myDocument.allGraphics.length-1; myCounter >= 0; myCounter--)
    Notice you have to use "length - 1" and check "myCounter >= 0", because the array elements are numbered from 0 to length-1 -- perfectly logical for a computer, somewhat less so for a human. The regular forwards loop does exactly the same, but it's a bit more 'hidden' from casual inspection.

  • Help with looped equation

    I am really struggling here with this (what seems) fairly simple labview problem.  I have a set of equations that rely on the answer of the previous other formula and so forth.  I can do this easily enough in excel.  I tried to recreate this function in labview and have been really struggling to get it to work.  I have tried using while loops and for loops, which I think is what I need to do here, but I haven't had much success.  Anyways, I attached the spreadsheet with the two formulas, a .png showing the relationship of the formulas in the spreadsheet, and my .VI.  Thanks for your help in advance.
    Solved!
    Go to Solution.
    Attachments:
    Formula.xlsx ‏42 KB
    Formula.png ‏38 KB
    Untitled 1.vi ‏8 KB

    You need both a loop and a shift register.
    Lynn
    Attachments:
    Looped equations.2.vi ‏10 KB

  • Help with Loops!! All loops are RED and unclickable after Leopard upgrade.

    I may need to just remove soundtrack pro from my computer and start from scratch again. When I upgraded to Leopard I failed to select preserve user settings when I did an archive and install. So therefore I had to find and drag files to the new library. This is on my Power Mac G5.
    I have a Macbook Pro laptop and I used that as a guide of how I have that set up. On my G5, I have all my loops in the same folders they are in on my laptop. When I open STP, and pull up my loop files, they are all listed in red. When I try to click on them, nothing happens.
    I have them set up as MAC>Library>Audio>Apple Loops>Apple Loops for Soundtrack Pro, Apple Loops for GarageBand, PowerFX Loops
    I am not sure if I am dealing with a bunch of corrupt files and need to start with a new slate or what.
    I also noticed that most if not all the audio loops end in .CAF instead of .AIFF in the folders. However when STP is open, the files ARE listed as .aiff files but they are red and non clickable.
    Any suggestions appreciated!
    Thanks!
    Message was edited by: DVX100Shooter
    Message was edited by: DVX100Shooter
    Message was edited by: DVX100Shooter

    Yea once I rearranged the loops and then opened STP and then Indexed those loops, I got everything back to normal except my Trumpet files. I cannot locate them anywhere. There are only 4 loops but I searched my HD and still can't locate where they are but I got everything else back to working.

  • Need help with loops! Where can I find them?

    I have garageband '09 and when I go through my loops, over half of them are missing. That is to say they are labeled and there is a list of them, but only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update but it always comes back that everything is up to date. im wondering if they might be in a folder and garageband doesnt know of that folder as where to look or what. Any Ideas please??

    Bachman22 wrote:
    only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update
    http://www.bulletsandbones.com/GB/GBFAQ.html#cantdownloadloops
    (Let the page FULLY load. The link to your answer is at the top of your screen)

Maybe you are looking for