Note that there are some explanatory texts on larger screens.

plurals
  1. POWaiting function has logic error
    primarykey
    data
    text
    <p>I have created an program that automates certain functions at my place of business but I'm trying to dummy proof it so it cannot go wrong and I have encountered an error that should not be occurring. </p> <p>Basically what my method is doing is waiting until the spreadsheet has stopped being populated and auto formatted so I can do some other stuff with it. All this method has to do is take a screen shot, wait, take another screen shot and if they are the same then continue, if not wait some more. </p> <p>here are the methods. </p> <pre><code>private boolean WaitTillDone() { BufferedImage image1; BufferedImage image2; image1 = siri.createScreenCapture(new Rectangle(0,0,width,height-80)); wait(4000); image2 = siri.createScreenCapture(new Rectangle(0,0,width,height-80)); boolean same = bufferedImagesEqual(image1,image2); return same; } public boolean bufferedImagesEqual(BufferedImage img1, BufferedImage img2) { if (img1.getWidth() == img2.getWidth() &amp;&amp; img1.getHeight() == img2.getHeight() ) { for (int x = 0; x &lt; img1.getWidth(); x++) { for (int y = 0; y &lt; img1.getHeight(); y++) { if (img1.getRGB(x, y) != img2.getRGB(x, y) ) return false; } } } else { return false; } return true; } </code></pre> <p>Here is the loop that this is being called in.</p> <pre><code>do{ running = WaitTillDone(); wait(800); }while(running); </code></pre> <p>The program loops ok but sometimes when the images are not the same and it has to wait it will enter an "infinite" loop. I say "infinite" because without any user input it will not continue. However if I press any arrow button or enter just to move the selected box in excel so that the images will be different it will continue along with no problems. So i was wondering if there was anything that I was doing wrong (besides calling a wait (a Thread.sleep) in a loop) that would cause my program to have this logic error.</p> <p>EDIT: This problem is not occurring every time, only about 1/4th of the time. This problem is resolved, the mistake was the do-while condidtion. It was supposed to be </p> <pre><code>do{ running = WaitTillDone(); wait(800); }while(!running); </code></pre> <p>Thank you all for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload