FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Turning a string[] into a buncha chars
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Turning a string[] into a buncha chars  (Read 307 times)
_bula


Turning a string[] into a buncha chars
« on: Jul 11th, 2004, 12:47am »

I'm new at this "really programming" thing and I've run into a brick wall with my latest challenge.
 
THE GOAL:
I want this sketch to be an interactive block of text which can be imported from a remote text file (mostly because there will be an abundance of text). For an all "a" example goto http://www.carambula.com/processing/a_block.html
 
THE PROBLEM(s):
I need to import the text, which meens it will be a string array, even with a non-formatted text file. I've been using substring to get the individual letters into the individual objects, I can successfully load the text from a txt file, but for some reason I can't join the incoming string array in order to crawl it and get the individual characters. These bits of code are in the example, but I commented them out.
 
I have other issues, too. I'd like to see this block of text eventually containing all punctuation and spaces. I am also, like I said, an extreme novice, and I'd really appreciate some clear explanations. I can pick up on things, but I'm struggling to find sources of specific information.
 
Thanks so much in advance, just from my reading in these forums, this is an awesome community. If there's anything further you need from me to better understand my plight, by all means, yell at me a bit and I'll respond ASAP.
 
mattgilbert

tangramkid WWW Email
Re: Turning a string[] into a buncha chars
« Reply #1 on: Jul 11th, 2004, 2:03am »

String wordsAndSuch = "blah";
char[] data = String.toCharArray(wordsAndSuch);
 
For other string tricks you can check http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html  
 
The java APIs will tell you what you can do in java that hasn't been worked into processing.
 
Matt
 
_bula


Re: Turning a string[] into a buncha chars
« Reply #2 on: Jul 11th, 2004, 5:08am »

Thanks, I appreciate the quick response!
I was wondering, though, if there is a way to do that with a string array, especially when I get errors joining said array.  
 
String raw[] = loadStrings("modernmajor2.txt");
String song = join(raw,"");
 
This for some reason isn't working. modernmajor2.txt has no spaces or punctuation (which I hope to somehow remedy, once I figure out the problem). I have tried formatting with a deliminator, but that doesn't work either.
 
Thanks for the link, the more resources like that the better. Can that java code be directly inserted into my processing sketch?
 
Thanks for the help!
 
narain


Re: Turning a string[] into a buncha chars
« Reply #3 on: Jul 11th, 2004, 6:57am »

Processing pretty much is just Java, so yes, you can use in Processing anything you can use in Java.
 
Which is why learning a little Java can be very handy for making complex sketches. There's a great tutorial on Learning the Java language at Sun's site. (Sun make Java, btw.)
 
There shouldn't be any problem with punctuation or spaces, I think: they're all chars to Java...
 
What problems are you getting with join()? I tried joining a String array with "", and it worked for me...
 
_bula


Re: Turning a string[] into a buncha chars
« Reply #4 on: Jul 12th, 2004, 4:30pm »

Thanks for the help! I got it to work, now I need to figure out a way to make it functional!
 
Aaron
 
Pages: 1 

« Previous topic | Next topic »