# Having trouble with code

**URL:** <https://discourse.processing.org/t/having-trouble-with-code/28446>\
**Category:** Beginners\
**Created:** [March 11, 2021, 5:45pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446 "2021-03-11T17:45:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lolman223](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@Lolman223](https://discourse.processing.org/u/Lolman223)\
**Post date:** [March 11, 2021, 5:45pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/1 "2021-03-11T17:45:46Z")

</div>

I’m having trouble figuring out why line 19 (t+=0.5;) is unreachable. Can somebody have a look, please?

```auto

static final int NUM_LINES = 10;

float t;

void setup() {
  background(20);
  size(500,500);
}

void draw() {
  background(20);
  stroke(255);
  strokeWeight(5);
  translate(width/2, height/2);
  for (int i = 0; 1 < NUM_LINES; i++) {
   line(x1(t+i),y1(t+i),x2(t+i),y2(t+i));
  }
  t+=0.5;
}

float x1(float t){
  return sin(t/10) * 100 + sin(t/5) * 20;
}

float y1(float t){
  return cos(t/10) * 100;
}

float x2(float t){
  return sin(t/10) * 100 + sin(t) * 2;
}

float y2(float t){
  return cos(t/20) * 200 + cos(t/12) * 20;
}

```

---

<div class="post-metadata">

**Author:** ![richhelvey](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@richhelvey](https://discourse.processing.org/u/richhelvey)\
**Post date:** [March 11, 2021, 6:05pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/2 "2021-03-11T18:05:32Z")

</div>

First, your for loop is wacky. You want to be checking the value of i, but instead you’ve accidentally put 1

Change  
for (int i = 0; 1 \< NUM\_LINES; i++)  
to  
for (int i = 0; i \< NUM\_LINES; i++)

But that shouldn’t keep you from getting to the next line, it should just prevent the loop from running.

But that next line adds 0.5 to t. What does t equal before this? You never initialize it.

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [March 11, 2021, 6:06pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/3 "2021-03-11T18:06:02Z")

</div>

Hello, @Lolman223, and welcome to the Processing Foundation Forums!

You have this:

```auto
  for (int i = 0; 1 < NUM_LINES; i++) {

```

Due to the condition, `1 < NUM_LINES`, it is an infinite loop.

---

<div class="post-metadata">

**Author:** ![Lolman223](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@Lolman223](https://discourse.processing.org/u/Lolman223)\
**Post date:** [March 11, 2021, 6:10pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/4 "2021-03-11T18:10:15Z")

</div>

Thank you so much for your help

---

<div class="post-metadata">

**Author:** ![richhelvey](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@richhelvey](https://discourse.processing.org/u/richhelvey)\
**Post date:** [March 11, 2021, 6:10pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/5 "2021-03-11T18:10:51Z")

</div>

DOH! I got my \< and \> mixed up

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [March 11, 2021, 6:23pm UTC](https://discourse.processing.org/t/having-trouble-with-code/28446/6 "2021-03-11T18:23:37Z")

</div>

Hello, @richhelvey and welcome to the Processing Foundation Forums!

Yeah, with the condition corrected based on your observation, and with a proper initialization of `t`, the program will run, with all lines of code reachable, and with a nice animation to display.
