Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
vllasaliu.aid
vllasaliu.aid's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
string.getlength does not work?
[3 Replies]
24-Apr-2013 08:25 AM
Forum:
Core Library Questions
hi guys.
im getting an exception everytime i try to get the length of a string and I dont know how to fix this.
does anybody have an idea?
Heres my code:
import processing.serial.*;
Serial myPort; // Create object from Serial class
String SerialBuffer; // Data received from the serial port
void setup()
{
size(500,128);
String portName = Serial.list()[5];
myPort = new Serial(this, portName, 115200);
}
void draw()
{
background(0);
stroke(255);
if ( myPort.available() > 0) { // If data is available,
SerialBuffer = myPort.readString(); // read it and store it in val
}
if (SerialBuffer==""){
}
else{
int BufLen = BufLen=SerialBuffer.length();
//Here is where I get a NullPointerException
for (int i=0; i<129; i++){
char c = SerialBuffer.charAt(i);
// line( i, height, i, height-c);
}
}
}
«Prev
Next »
Moderate user : vllasaliu.aid
Forum