Why the text file shows messy date saved by output.println

edited May 2015 in Questions about Code

I try to used output.println to save data (which from println) in a text file, but the data in the output text file is unreadable. I hope some friends can help me solve this problem.

Here is my code:

PrintWriter output;

float x,y,e;
int plate_width=50, plate_height=50;
boolean UP=true;
boolean RIGHT=true;

void setup(){
  size(100,100);
  x=40;
  y=40;
  output = createWriter("gcode.doc");
}

void draw(){
  if (UP) {
  y=y+0.2;
} else {
  y=y-0.2;
}
  
 if (y>=plate_height) {
  x=x+0.2;
  UP=false;
  
 }
 
 if (y<=40) {
   UP=true;
   x=x+0.2;
 }
 
 if (x>plate_width) {
   stop();
 }
 
 String[] gcode=new String[7];

gcode[0]="G1";

gcode[1]="X";
gcode[2]=str(x);
gcode[3]="Y";
gcode[4]=str(y);
gcode[5]="E";
gcode[6]=str(e);

String[] str=new String[4];
str[0]=gcode[0];
str[1]=gcode[1]+gcode[2];
str[2]=gcode[3]+gcode[4];
str[3]=gcode[5]+gcode[6];
e=e+0.04488;


str=append(str,"");

println(str);

output.println(str);
}

Answers

Sign In or Register to comment.