# Why is the program ignoring my second for- loop?

**URL:** <https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 11, 2022, 11:30am UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819 "2022-05-11T11:30:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katharina](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Katharina](https://discourse.processing.org/u/Katharina)\
**Post date:** [May 11, 2022, 11:30am UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819/1 "2022-05-11T11:30:12Z")

</div>

Please help me, im a beginner in Processing.  
Before I’ll tell my problem I’ll twll you about the programm so u wont get confused.  
I want to create 2 arrows (left and right) they need to be next to eachother. I need 4 rows of these.  
I made te arrows with a picture and tried to make them using a for loop( so I don’t have to create every single arrow and place it). The first for loop is a sucess but the second one doesn’t want to listen.  
Is there a way to fix this or did I go the wrong eay and need to programm it in a different way?  
Here’s the code:

> \<  
> PImage pfeilRechts;  
> PImage pfeilLinks;  
> int pU= 35;  
> int p1Y= 230;  
> int p1Y2= 340;  
> int p1X= 45;  
> int p1X2= 80;  
> int arrow;  
> void setup() {  
> size(800, 600);  
> arrowLeft= loadImage(“PfeilLinks.png”);  
> arrowRight= loadImage(“PfeilRechts.png”);  
> }  
> void draw() {  
> createArrowFirstRow();  
> createArrowSecondRow();  
> }  
> }  
> void createArrowFirstRow(){  
> for(int i=0; arrow\<5; arrow++){//Arrow ++ damit so it won’r repeat again  
> imageMode(CENTER);  
> image(arrowLeft, p1X, p1Y, pU, pU);  
> p1X+=75;  
> image(arrowRight, p1X2,p1Y, pU, pU);  
> p1X2+=75;  
> }  
> }  
> void createArrowSecondRow();(){  
> for(int i=0; arrow \<5; arrow++){//Arrow ++ damit so it won’t repeat again  
> imageMode(CENTER);  
> image(arrowLeft, p1X, p1Y2, pU, pU);  
> p1X+=75;  
> image(arrowRight, p1X2,p1Y, pU, pU);  
> p1X2+=75;  
> }  
> }  
> \<

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 11, 2022, 11:42am UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819/2 "2022-05-11T11:42:16Z")

</div>

> [@Katharina](#):
>
> for(int i=0; arrow\<5; arrow++){

normally we use three times the same variable:

`for(int arrow=0; arrow<5; arrow++){`

since arrow is 5 (after the 1st for loop) in your approach, in the second for-loop the condition arrow \<5 is not met so the 2nd for-loop doesn’t run

---

<div class="post-metadata">

**Author:** ![Katharina](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Katharina](https://discourse.processing.org/u/Katharina)\
**Post date:** [May 11, 2022, 1:52pm UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819/3 "2022-05-11T13:52:35Z")

</div>

thank you for your reply. I’ve tried using three times the same variable but then thr pictures wouldn’t stop being produced. How do I code the for loop to work?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 11, 2022, 2:42pm UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819/4 "2022-05-11T14:42:23Z")

</div>

You can say noLoop(); in draw() or reset the variables that you increase (reset them at the start of draw ())

Use background at start of draw
