Beginner Struggling with String Arrays
in
Programming Questions
•
2 years ago
Hi everyone,
I am a total beginner to processing, so please forgive me if this is a really question, but I can just not get it work!
I have a piece of processing code which performs a yahoo search, and saves the result descriptions in a string array. I want to send this information to arduino to then print it out from a receipt printer. As I believe, arduino can't handle strings, but uses char arrays instead, so I am trying to convert my string array into a two dimensional char array to then send to arduino.
Any help you could give me would be fantastic!
- import pyahoo.*;
- import com.yahoo.search.WebSearchResults;
- import processing.serial.*;
- Serial port;
- // Create a YahooSearch object. You have to pass in the API key given to you by Yahoo.
- YahooSearch yahoo;
- char [][]target;
- void setup() {
- size(200,200);
- port = new Serial(this,Serial.list()[1], 9600);
- // Make a search object, pass in your key
- yahoo = new YahooSearch(this, "B5rzyEvV34EjE7c3OWj3BWOXBrP3f.b3HF9hLPGyB0r5CopLwlFLrvhdw8X1.wQnPE3mtihee94-");
- }
- void mousePressed() {
- // Search for a String. By default you will get back 10 results.
- // If you want more (or less), you can request a specific number by saying:
- yahoo.search("Patrick", 5);
- }
- void draw() {
- noLoop();
- }
- // When the search is complete
- void searchEvent(YahooSearch yahoo) {
- String[] summaries = yahoo.getSummaries();
- char [][]target = new char[summaries.length][];
- for (int i=0; i<summaries.length; i++) {
- target[i] = summaries[i].toCharArray();
- }
- }
1