# Please help me TT

**URL:** <https://discourse.processing.org/t/please-help-me-tt/12098>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [June 16, 2019, 2:33pm UTC](https://discourse.processing.org/t/please-help-me-tt/12098 "2019-06-16T14:33:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apple](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@apple](https://discourse.processing.org/u/apple)\
**Post date:** [June 16, 2019, 2:33pm UTC](https://discourse.processing.org/t/please-help-me-tt/12098/1 "2019-06-16T14:33:13Z")

</div>

* * *

```auto
String a = "1,235,345,234,123,234,345.\n"; //channel(0,1,2),value,value,value,value,value,value.\n
String[] temp = split(a,',');
String CH = temp[0].replace("\n","");

//int value1 = int(temp[1]);
//int value2 = int(temp[2]);
//int value3 = int(temp[3]);
//int value4 = int(temp[4]);
//int value5 = int(temp[5]);
//int value6 = int(temp[6].replace(".",""));

if (CH == "0") {
  println("CH is 0");
}
else if (CH == "1") {
  println("CH is 1");
}
else if (CH == "2") {
  println("CH is 2");
}
println("completed"); 

```

* * *

I made this code, and I expected  
“CH is 1”  
“completed”

but it shows only  
“completed”

so I tryed this on [https://hello.processing.org/editor/#editor](https://hello.processing.org/editor/#editor)  
and it worked well  
please let me know why my processing does not show “CH is 1”

I’m not good at English, sorry

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [June 16, 2019, 2:53pm UTC](https://discourse.processing.org/t/please-help-me-tt/12098/2 "2019-06-16T14:53:57Z")

</div>

```auto
String a = "1,235,345,234,123,234,345.\n";
String[] temp = split(a,',');
String CH = temp[0].replace("\n","");

if (CH.equals("0")) println("CH is 0");
else if (CH.equals("1")) println("CH is 1");
else if (CH.equals("2")) println("CH is 2");
println("completed");

```

shows

```auto
CH is 1
completed

```

pls see  
[https://processing.org/reference/String\_equals\_.html](https://processing.org/reference/String_equals_.html)

and understand that the way you posted your code  
makes it unusable.

also the 3d line code is wrong, as it looks for temp[0] ( “1” )  
but the “\n” is in temp[6]  
please use a print after each operation to understand what it does.

---

<div class="post-metadata">

**Author:** ![apple](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@apple](https://discourse.processing.org/u/apple)\
**Post date:** [June 17, 2019, 10:47am UTC](https://discourse.processing.org/t/please-help-me-tt/12098/3 "2019-06-17T10:47:26Z")

</div>

It works very well, thank you

---

<div class="post-metadata">

**Author:** ![apple](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@apple](https://discourse.processing.org/u/apple)\
**Post date:** [June 22, 2019, 1:47pm UTC](https://discourse.processing.org/t/please-help-me-tt/12098/4 "2019-06-22T13:47:10Z")

</div>

I’m so sorry but problem occured again  
My arduino sends  
0,value,value,value,value,value,value.  
1,value,value,value,value,value,value.  
2,value,value,value,value,value,value.  
0,value,value,value,value,value,value.  
.  
.  
.  
by serial

I thought “\n” is in temp[0]  
So i placed replace("\n","") to temp[0]  
But it only prints  
“completed”  
“completed”  
“completed”  
.  
.  
.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 22, 2019, 5:02pm UTC](https://discourse.processing.org/t/please-help-me-tt/12098/5 "2019-06-22T17:02:32Z")

</div>

> [@kll](#):
>
> the “\n” is in temp[6]

The first three lines of your code do this:

`String a = "1,235,345,234,123,234,345.\n";`

Makes a string with a linebreak (\n) at the end:

> 1,235,345,234,123,234,345.  
> &nbsp;

`String[] temp = split(a,',');`

Turns it into an array:

0: `1`  
1: `235`  
2: `345`  
3: `234`  
4: `123`  
5: `234`  
6:

> 1. 
> 
> &nbsp;

Notice that last one still has a period and a linebreak at the end.

`String CH = temp[0].replace("\n","");`

Removes any linebreaks from [0]. There aren’t any, so it does nothing.

[6] still has a period and a linebreak at the end.
