We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am making a piece of code and I have a string[] declared called recs. I have lots of debug println(recs); in the code and they all return something that looks similar to [Ljava.lang.String;@7638c30f. I am using the networking library and sound library.
import processing.net.*;
import processing.sound.*;
Server server;
String rec;
String[] recs = {"0"};
String[] tables = {};
String[] blank = {};
void settings() {
fullScreen();
}
void setup(){
size(displayWidth,displayHeight,P2D);
background(255,255,244);
server = new Server(this, 5204);
println("recs debug:" + recs);
for(int i = 0; i < loadStrings("data/data/tables.txt").length; i++) {
for(int s = 1; s < split(loadStrings("data/data/tables.txt")[i], "$").length; s++) {
tables = append(tables, split(loadStrings("data/data/tables.txt")[i], "$")[0] + split(loadStrings("data/data/tables.txt")[i], "$")[s]);
}
}
}
void draw(){
imageMode(CENTER);
textAlign(CENTER);
textSize(20);
fill(0);
Client client = server.available();
if (client != null) {
String incomingMessage;
incomingMessage = client.readString();
incomingMessage = incomingMessage.trim();
recs = new String[] {};
println("Recieved: " + incomingMessage);
rec = incomingMessage;
println("recs before:" + recs);
recs = split(rec, "$");
println("recs after:" + recs);
refresh();
}
}
void refresh(){
String[] table = {};
table = loadStrings("data/data/" + recs[0] + ".txt");
println("table:" + table);
println("recs:" + recs);
println("rec:" + rec);
if(table[0] == "done"){
saveStrings("data/data/" + recs[1] + ".txt", blank);
}else{
for(int i = 1; i < (recs.length-1); i++) {
table = append(table, recs[i]);
saveStrings("data/data/" + recs[0] + ".txt", table);
}
}
}
void serverEvent(Server server, Client client) {
println(" A new client has connected: "+ client.ip());
}
Answers
I know you tried, but...
Format your code. Edit your post (gear on top right side of any of your posts), select your code and hit
ctrl+o
. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-textIt is not difficult. You will get more attention if you format all your posts according to the provided link.
Kf
ah okay ctrl+o thanks
println("recs after:" + recs);
is not the same as
println(recs);
The first one will print the address reference of the object. The second one should print the content of the object. Give it a try and see if it does what you want.
Kf
thanks!! yeah, i guess if there's a string in front of it, it wouldn't want to print out the whole array behind it.
You also could make a function to return the content of the array:
String getArrayAsText() {
String result = „“;
for(int i.....
result =result + ..... + „\n“;
return result;
}
The „“ must be normal „“ but my @&€& iPhone is changing those