From 3cc0fe47f4760db0319c63f650963d2dacf6c687 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 10 Jul 2004 00:21:14 +0000 Subject: [PATCH] added str() function --- processing/core/PApplet.java | 144 +++++++++++++++++++++++++++++++++-- processing/todo.txt | 4 +- 2 files changed, 142 insertions(+), 6 deletions(-) diff --git a/processing/core/PApplet.java b/processing/core/PApplet.java index 22c612a28..feb98253e 100644 --- a/processing/core/PApplet.java +++ b/processing/core/PApplet.java @@ -926,11 +926,50 @@ public class PApplet extends Applet System.out.flush(); } - static public void print(Object what) { - System.out.print(what.toString()); + //static public void print(Object what) { + //System.out.print(what.toString()); + //System.out.flush(); + //} + + // + + static public void print(boolean what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); System.out.flush(); } + static public void print(char what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); + System.out.flush(); + } + + static public void print(int what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); + System.out.flush(); + } + + static public void print(float what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); + System.out.flush(); + } + + static public void print(double what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); + System.out.flush(); + } + + static public void print(String what[]) { + for (int i = 0; i < what.length; i++) System.out.print(what[i]); + System.out.flush(); + } + + //static public void print(Object what[]) { + //for (int i = 0; i < what.length; i++) System.out.print(what[i]); + //System.out.flush(); + //} + + // + static public void println(boolean what) { print(what); System.out.println(); } @@ -955,14 +994,51 @@ public class PApplet extends Applet print(what); System.out.println(); } - static public void println(Object what) { - System.out.println(what.toString()); - } + //static public void println(Object what) { + //System.out.println(what.toString()); + //} static public void println() { System.out.println(); } + // + + static public void println(boolean what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + static public void println(char what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + static public void println(int what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + static public void println(float what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + static public void println(double what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + static public void println(String what[]) { + for (int i = 0; i < what.length; i++) System.out.println(what[i]); + System.out.flush(); + } + + //static public void println(Object what[]) { + //for (int i = 0; i < what.length; i++) System.out.println(what[i]); + //System.out.flush(); + //} + // ------------------------------------------------------------ @@ -1816,6 +1892,64 @@ public class PApplet extends Applet // number formatting - integers + static public String str(boolean x) { return String.valueOf(x); } + static public String str(byte x) { return String.valueOf(x); } + static public String str(char x) { return String.valueOf(x); } + static public String str(short x) { return String.valueOf(x); } + static public String str(int x) { return String.valueOf(x); } + static public String str(float x) { return String.valueOf(x); } + static public String str(long x) { return String.valueOf(x); } + static public String str(double x) { return String.valueOf(x); } + + static public String[] str(boolean x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(byte x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(char x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(short x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(int x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(float x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(long x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + static public String[] str(double x[]) { + String s[] = new String[x.length]; + for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x); + return s; + } + + /** * Integer number formatter. */ diff --git a/processing/todo.txt b/processing/todo.txt index dc9c24f85..61c6949b4 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -249,13 +249,15 @@ X move around notes about curve stuff 040708 later X working on serial library -040709 +040709 daytime X fight with serial library on windows all afternoon X finish and test on macosx as well X remove chatter in PdeSketchbook re: filenamefilter X COM1 19200 for phone X add "available" function to PSerial +040709 evening + _ error in System.err stream coming from running external _ dies after a while or goes weird