<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with indexof() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=indexof%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:43:34 +0000</pubDate>
         <description>Tagged with indexof() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedindexof%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Error, disabling serialEvent()</title>
      <link>https://forum.processing.org/two/discussion/28124/error-disabling-serialevent</link>
      <pubDate>Sat, 22 Sep 2018 19:34:23 +0000</pubDate>
      <dc:creator>laptophead</dc:creator>
      <guid isPermaLink="false">28124@/two/discussions</guid>
      <description><![CDATA[<p>The full message I am getting is: Error, disabling serialEvent() for /dev/cu.usbmodem2574541
null</p>

<p>The sketch will get the data one time than it hangs on this message.</p>

<p>Here is my code;   I am getting the data from an arduino teensy 3.5
Please help.</p>

<p>Thanks</p>

<p>import processing.serial.*;
Serial port;
int BaseEncGlobal;
int ElbowEncGlobal;
int ShoEncGlobal;
int VertRotEnc;
int HorRotEnc;
int GripEncGlobal;</p>

<p>double X_axis;
double Y_axis;
double Z_axis;
double GripAngle;</p>

<p>String data;
boolean newData = false;</p>

<p>PFont font;</p>

<p>void setup()
{
  size(1280,800);
  //port =  new Serial(this, "/dev/cu.usbserial-A50285BI", 115200);
  port =  new Serial(this, "/dev/cu.usbmodem2574541", 115200);
  port.bufferUntil('\n'); 
  font = loadFont("AgencyFB-Bold-200.vlw");
  textFont(font, 40);
}</p>

<p>void draw()</p>

<p>{ if (newData == true) {</p>

<p>int spaceDown = 55;
  background(0,0,0);
  fill(46, 209, 2);
  text(BaseEncGlobal, 70, spaceDown);
  fill(0, 102, 153);
  text(ShoEncGlobal, 70, spaceDown<em>2);
  fill(0, 102, 153);
 text(ElbowEncGlobal, 70, spaceDown</em>3);
  fill(0, 102, 153);
 text(VertRotEnc, 70, spaceDown<em>4);
  fill(0, 102, 153);
text(HorRotEnc, 70, spaceDown</em>5);
  fill(0, 102, 153);
  text( GripEncGlobal, 70, spaceDown*6);</p>

<p>text(Double.toString(X_axis/10), 270, spaceDown );
newData =false;
}</p>

<p>}</p>

<p>void serialEvent (Serial port)
{</p>

<p>data = port.readStringUntil('\n');
 if (data != null)
 {
 data = trim(data);</p>

<p>int[] nums = int(split(data, ','));
 BaseEncGlobal =  nums [1];
 ShoEncGlobal  =  nums [2];
 ElbowEncGlobal =  nums [3];
 VertRotEnc    =  nums [4];
 HorRotEnc     =  nums [5];
 GripEncGlobal =  nums [6];
 X_axis =  nums [7];
  Y_axis =  nums [8];
   Z_axis =  nums [9];
    GripAngle =  nums [10];
 //println(Double.toString(X_axis/10));</p>

<p>println(data);</p>

<p>newData = true;
 }</p>

<p>}</p>

<p>/*</p>

<p>void serialEvent (Serial port)
{
  data = port.readStringUntil('.');
  data = data.substring(0, data.length() - 1);</p>

<p>// look for the comma between Celcius and Farenheit
  index = data.indexOf(",");
  // fetch the C Temp
  temp_c = data.substring(0, index);
  // fetch the F Temp
  //temp_f = data.substring(index+1, index);
  temp_f = data.substring(1, data.length());</p>

<pre><code>ElbowEncGlobal =  getValue(data, ',', 2);
</code></pre>

<p>}
*/</p>
]]></description>
   </item>
   <item>
      <title>Unable to use substring() function within an array. (Parsing irishrail)</title>
      <link>https://forum.processing.org/two/discussion/27687/unable-to-use-substring-function-within-an-array-parsing-irishrail</link>
      <pubDate>Wed, 04 Apr 2018 01:03:33 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27687@/two/discussions</guid>
      <description><![CDATA[<p>I am getting an error when I attempt to use substring() as I iterate through an array. I want to extract an integer from a string of text. This works fine outside of an array:</p>

<pre><code>    String trainInfo = "E215\n17:30 - Howth to Bray (-3 mins late)\nArrived Dublin Connolly next stop Tara Street";
    int start      = trainInfo.indexOf("(" ) + 1;  // STEP 1 
    int end        = trainInfo.indexOf(" mins", start);      // STEP 2
    String status  = trainInfo.substring(start, end);    // STEP 3
    int status_no   = int(status);                    // STEP 4
    println(status_no);
</code></pre>

<p>Whereas in my case I get an error at the point of the substring():</p>

<pre><code>    void requestData() {   
      for (int i = 0; i &lt; children.length; i++) {     

        XML announcementElement = children[i].getChild("PublicMessage");
        String announcement = announcementElement.getContent(); 

        int start      = announcement.indexOf("(" ) + 1;        // STEP 1 
        int end        = announcement.indexOf(" mins", start);  // STEP 2
        String status  = announcement.substring(start, end);    // STEP 3    ***error thrown at this point***
        int status_no   = int(status);                          // STEP 4

        println(status_no);
      }
    } 
</code></pre>

<p>[edit] Though not strictly related to Processing, I found a thread in the following forum that indicates that javascript does not permit substrings within arrays. I guess the same applies to Processing?:
<a rel="nofollow" href="https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function">https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function</a></p>

<p>The responder recommends to "slice and then remove the commas" or to use join(''). I have tried to to slice() and join(), based on Processing documentation but it's not working out.</p>

<p>Would anyone know of a way to get around this? Many thanks :)</p>
]]></description>
   </item>
   <item>
      <title>Find the nth occurrence of a specific character in a String</title>
      <link>https://forum.processing.org/two/discussion/23582/find-the-nth-occurrence-of-a-specific-character-in-a-string</link>
      <pubDate>Tue, 25 Jul 2017 23:08:23 +0000</pubDate>
      <dc:creator>albobz</dc:creator>
      <guid isPermaLink="false">23582@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to write a function that returns the integer index value for the nth occurrence of a specified character c, like:</p>

<pre><code>int findNthChar(String a, char c, int n)
</code></pre>

<p>I know to use a while loop but am not too sure of the code within it.</p>
]]></description>
   </item>
   <item>
      <title>determine if a String is numeric (only int, not float, but minus sign allowed)...?</title>
      <link>https://forum.processing.org/two/discussion/23275/determine-if-a-string-is-numeric-only-int-not-float-but-minus-sign-allowed</link>
      <pubDate>Sat, 01 Jul 2017 08:29:22 +0000</pubDate>
      <dc:creator>Chrisir</dc:creator>
      <guid isPermaLink="false">23275@/two/discussions</guid>
      <description><![CDATA[<p>hello all,</p>

<p>more simple way of a function to determine if a String is numeric?</p>

<p>Thank you all!</p>

<p>Best, Chrisir....  ;-)</p>

<pre><code>void setup() {
  println(isNumeric("---"));
}

void draw() {
  //
}

boolean isNumeric(String testWord) {
  // for int numbers, not float  

  // first we check if a wrong char is present 
  for (int i=0; i&lt;testWord.length(); i++) {
    if ("0123456789-".indexOf(testWord.charAt(i))&lt;0) {
      return false;  // abort with false
    }//if
  }//for

  // second: to avoid that testWord might be "---"
  // we need to find one number at last 
  boolean foundOne = false; 
  for (int i=0; i&lt;testWord.length(); i++) {
    if ("0123456789".indexOf(testWord.charAt(i))&gt;=0) {
      foundOne = true;
    }//if
  }//for

  if (!foundOne) 
    return false; // abort with false

  // do we have a minus?
  if (testWord.contains("-")) {
    // only one minus allowed 
    int countMinus=0;
    for (int i=0; i&lt;testWord.length(); i++) 
      if (testWord.charAt(i)=='-')
        countMinus++;
    if  (countMinus&gt;1) 
      return false;
    // -------------------
    if (testWord.indexOf('-')!=0) // - must be first char like in -12 
      return false;  // abort with false
  }

  return true; // success 
}//func
</code></pre>
]]></description>
   </item>
   <item>
      <title>Multiplayer TCP/IP server &amp; client via Processing and Java</title>
      <link>https://forum.processing.org/two/discussion/23159/multiplayer-tcp-ip-server-client-via-processing-and-java</link>
      <pubDate>Wed, 21 Jun 2017 18:20:13 +0000</pubDate>
      <dc:creator>GeorgeJava</dc:creator>
      <guid isPermaLink="false">23159@/two/discussions</guid>
      <description><![CDATA[<p>i have problem with this...</p>

<p>input = input.substring(2, input.indexOf("\n")); // &lt;-- ??? what is number: 2 ?</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/715/MFFVH7SV4CES.png" alt="error" title="error" /></p>
]]></description>
   </item>
   <item>
      <title>How to display element# of ArrayList as text</title>
      <link>https://forum.processing.org/two/discussion/23044/how-to-display-element-of-arraylist-as-text</link>
      <pubDate>Tue, 13 Jun 2017 02:19:09 +0000</pubDate>
      <dc:creator>Nicho247</dc:creator>
      <guid isPermaLink="false">23044@/two/discussions</guid>
      <description><![CDATA[<p>Hello - 
New to processing. I have been following some YouTube tutorial videos by Daniel Shiffman @ Coding Train. I really liked his video on the Menger Sponge Fractal. I going to fold in some stuff about primes with his code from the video. Before I get there, I want to display the element# of an Array as text. Am a little confused with ArrayLists and can't get the syntax quite right. Any help would be great. To re-iterate, there is a 3d rotating series of boxes drawn, and they are all part of the ArrayList. I want to display with text, in each box the element position of that box in the box.</p>

<p>just showing the code on 1 of the two files (from Daniel Shiffman), as it is in the correct place (afaik)...</p>

<p>text('hi', 0,0,0); // this will have each 3-D box have 'hi' in the center. I don't know what to replace 'hi' with in order to display the element position of the ArrayList. The text function wants an int value in this position. Conflating this, the code is using push/pop which I am not too familiar with.</p>

<pre><code>class Box {
 PVector pos;
 float r;

 Box(float x, float y, float z, float r_) {
   pos = new PVector(x, y, z);
   r = r_;
 }

 ArrayList&lt;Box&gt; generate() {
  ArrayList&lt;Box&gt; boxes = new ArrayList&lt;Box&gt;();
  for (int x = -1; x &lt; 2; x++) {
    for (int y = -1; y &lt; 2; y++) {
      for (int z = -1; z &lt; 2; z++) {
        float newR = r/3;

        Box b = new Box(pos.x + x*newR,
                        pos.y + y*newR,
                        pos.z + z*newR,
                                  newR);
        int sum = abs(x) + abs(y) + abs(z);
          if (sum &gt; 1) {
            boxes.add(b);
          }
      }
    }
  }
  return boxes;
 }

 void show() {
  pushMatrix();
  translate(pos.x, pos.y, pos.z);
  text(sponge.Box, 0,0,0); // this is where I need help. sponge.Box is incorrect
  noStroke();
  fill(255, 100);
  box(r);
  popMatrix();
 }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Integrating Arduino and Processing - button counter</title>
      <link>https://forum.processing.org/two/discussion/17602/integrating-arduino-and-processing-button-counter</link>
      <pubDate>Wed, 20 Jul 2016 22:39:13 +0000</pubDate>
      <dc:creator>ksenia_n</dc:creator>
      <guid isPermaLink="false">17602@/two/discussions</guid>
      <description><![CDATA[<p>I am looking to integrate Arduino controls and Processing Interface. In my Arduino code, there are three buttons attached to pin a1, a0 and d0 (all digitalRead).</p>

<pre><code>int x;// assigned to A0 input
int y;// assigned to A1 input
int z; //assigned to D0 input
int votes[3]={0,0,0};

void setup() {
  // initialize the serial communication
  Serial.begin(9600);

  while(!Serial);
}

void loop() {
  // first we need to read the values from the BUTTONS

  x = digitalRead(A0);

  y = digitalRead(A1);

  z = digitalRead(0);

  if(digitalRead(A0) == HIGH) 
    {
    Serial.print("cat1 ");                  
    Serial.print(votes[0]=votes[0]+1);
    Serial.print("\n");
    }
   else if(digitalRead(A1) == HIGH)
    {
    Serial.print("cat2 ");
    Serial.print(votes[1]=votes[1]+1);
      Serial.print("\n");
    }
   else if(digitalRead(0) == HIGH) 
    {
    Serial.print("cat3 ");
    Serial.print(votes[2]=votes[2]+1);
    Serial.print("\n");
    }
    delay(200);
}
</code></pre>

<p>I would like the counter to increment every time the button is pressed and display in processing as a bar graph. Whenever the button is pressed, the bar graph goes up by some amount. In this case I want one of the three lines (associated to three buttons) to draw, if pressed.</p>

<p>The processing code is below:</p>

<pre><code>import processing.serial.*;

// Serial Port variables
Serial myPort;
String buff = "";
String buff1 = "";
String buff2 = "";
int index = 0;
int NEWLINE = 10;
// Store the last 256 values from the sensors so we can draw them.
int[] valuesx = new int[256];
int[] valuesy = new int[256];
int[] valuesz = new int[256];

void setup()
{ 
  // set size of the window 
  size(512, 512);
  // turn on anti-aliasing, this makes things look smoother 
  smooth();

  println(Serial.list()); // use this to determine which serial port is your Arduino
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.bufferUntil('\n');
}

// draw() happens every frame of the sketch. This is where all the calculations are made.
// When draw() is finished executing, it executes again, over and over.
void draw() {
  // set the background to purple
  background(87, 36, 124);
  // set stroke weight(thickness of the line) to 5 pixels
  strokeWeight(5);

  for (int i = 0; i &lt; 255; i++) {

    stroke(247, i);
    // draw the line (x1, y1, x2, y2)
    line(1, valuesx[i], 1, valuesx[i + 1]);
    line(5, valuesy[i], 5, valuesy[i + 1]);
    line(10, valuesz[i], 10, valuesz[i + 1]);
  }

  // Check the Serial port for incoming data
  while (myPort.available () &gt; 0) {
    // if there is data waiting...
    // execute serialEvent() function. Look below to see how SerialEvent works.
    serialEvent(myPort.read());
  }
}

// serialEvent controls how incoming serial data from the Arduino module is handled
void serialEvent(int serial)
{
  if (serial != NEWLINE) {
    // Store all the characters on the line.
    buff += char(serial);
  } 
  else {
    // The end of each line is marked by two characters, a carriage
    // return and a newline.  We're here because we've gotten a newline,
    // but we still need to strip off the carriage return.
    buff = buff.substring(0, buff.length()-1);
    index = buff.indexOf(",");
    buff1 = buff.substring(0, index);
    buff2 = buff.substring(index+1, buff.length());

    // Parse the String into an integer.  We divide by 4 because
    // analog inputs go from 0 to 1023 while colors in Processing
    // only go from 0 to 255.
    int x = Integer.parseInt(buff1)/2;
    int y = Integer.parseInt(buff2)/2;

    // Clear the value of "buff"
    buff = "";

    // Shift over the existing values to make room for the new one.
    for (int i = 0; i &lt; 255; i++)
    {
      valuesx[i] = valuesx[i + 1];
      valuesy[i] = valuesy[i + 1];
    }

    // Add the received value to the array.
    valuesx[255] = x;
    valuesy[255] = y;
  }
}
</code></pre>

<p>Unfortunately, here's the error that I get when I press a button.
<img src="http://i.stack.imgur.com/U4WyU.jpg" alt="" /></p>
]]></description>
   </item>
   <item>
      <title>Searching for a string in a text file.</title>
      <link>https://forum.processing.org/two/discussion/16258/searching-for-a-string-in-a-text-file</link>
      <pubDate>Tue, 26 Apr 2016 00:30:34 +0000</pubDate>
      <dc:creator>dtools22</dc:creator>
      <guid isPermaLink="false">16258@/two/discussions</guid>
      <description><![CDATA[<p>Full disclosure, I'm very new to programming and very green.</p>

<p>What I'm attempting to do is build a program that has a series of "code words" it searches for in a standard text file.  If those words appear, some kind of function happens.  Here's the basic layout.</p>

<p>Read a text file.
Search the text file for the word "on".
When "on" is found print a message.
From this point forward in the text document, search for "off".
When "off" is found print a message.
Go back to searching for "on".</p>

<p>When end of the document is reached, I want the program to only search for new data and not keep rereading preexisting data.  Essentially I want the program to "remember where it is" so if something updates the text document it doesn't start from the beginning again.</p>

<p>Here is the code I have so far.  I've tested it a few times and have run into a problem.  The entire file is searched for "on" before the program searches for "off."  I want the program to search for "on" until an instance is found in the text file and then from that instance moving forward search for "off."</p>

<pre><code>String codeword1 = "on";
String codeword2 = "off";
int mySwitch = 0;


void setup(){



}

void draw(){
  String [] myfile = loadStrings("C:/Steven/Twitch/Testing Arduino Communication/String Test.txt");
  if (mySwitch == 0){
  for(int i = 0; i &lt; myfile.length; i++){
    String tobesearched = myfile[i];
    int index1 = tobesearched.indexOf(codeword1);
    if (index1 &gt;= 0){
      println("Light will be on");
      delay(1000);
      mySwitch = 1;

    }
    else {
      println("String not found");
      delay(1000);
    }

}
  }
  if (mySwitch == 1){
    for(int i = 0; i &lt; myfile.length; i++){
    String tobesearched = myfile[i];
    int index2 = tobesearched.indexOf(codeword2);
    if (index2 &gt;= 0){
      println("Light will be off");
      delay(1000);
      mySwitch = 0;

    }
    else{
      println("I don't want this text to appear");
      delay(1000);
    }
    }
  }
}
</code></pre>

<p>The text file I used to test this program looked like this with each word on its own line in the text file:</p>

<pre><code>Hello
There
on
RandomEntry
off
</code></pre>

<p>And the outputs of the programs were:</p>

<pre><code>String not found.
String not found.
Light will be on.
String not found.
String not found.
I don't want this text to appear.
I don't want this text to appear.
I don't want this text to appear.
I don't want this text to appear.
Light will be off.
</code></pre>

<p>And then looped back to the beginning.  Thanks in advance for any help.</p>
]]></description>
   </item>
   <item>
      <title>how to convert string to variable</title>
      <link>https://forum.processing.org/two/discussion/15323/how-to-convert-string-to-variable</link>
      <pubDate>Sun, 06 Mar 2016 20:08:38 +0000</pubDate>
      <dc:creator>Raz</dc:creator>
      <guid isPermaLink="false">15323@/two/discussions</guid>
      <description><![CDATA[<p>how can I convert String to variable? like:
<code>String a="int x=100";</code>
and now I will convert it to variable in the sketch. how to do this?</p>
]]></description>
   </item>
   <item>
      <title>Control de humedad, temperatura y presión desde PC con Processing</title>
      <link>https://forum.processing.org/two/discussion/14282/control-de-humedad-temperatura-y-presion-desde-pc-con-processing</link>
      <pubDate>Tue, 05 Jan 2016 23:23:55 +0000</pubDate>
      <dc:creator>MrSpock</dc:creator>
      <guid isPermaLink="false">14282@/two/discussions</guid>
      <description><![CDATA[<p>Hola.  Necesito hacer un fichero txt con los datos que mide un circuito arduino.  Por ello he pensado en hacer una pequeña aplicación para ejecutarla desde un pc con processing.  El tema es que necesito medir la humedad relativa y la temperatura por un lado, y la presión por otro lado, y recoger los datos en un fichero de texto de un ordenador.  Es evidente que necesito que se esté midiendo de forma contínua cada cierto tiempo para recoger un número de datos significativo para el estudio que debo hacer en un trabajo académico.</p>

<p>Aunque he estudiado programación en PASCAL hace ya algún tiempo, mis conocimientos de programación están bastante obsoletos, por lo cual el contacto con el JAVA y PROCESSING me está costando mucho trabajo.</p>

<p>Estudiando un poco por aquí y por allí he logrado hacer un código para un programa, pero me da problemas.  Y quisiera preguntar si alguno puede ayudarme en este proyecto, que imagino para algunos será relativamente fácil.</p>

<p>El código que he logrado hacer es el siguiente:</p>

<p>import processing.serial.*; //Importamos la librería Serial</p>

<p>Serial port; //Nombre del puerto serie</p>

<p>PrintWriter output;  //Para crear el archivo de texto donde guardar los datos</p>

<p>float valorP;//Valor de la presión<br />
float valorH;//Valor de la humedad relativa
float valorT;//Valor de la Temperatura
int index=0;</p>

<p>{
  println(Serial.list()); //Visualiza los puertos serie disponibles en la consola de abajo
  port = new Serial(this, Serial.list()[1], 9600); //Abre el puerto serie COM3</p>

<p>output = createWriter("Parametros_datos.txt"); //Creamos el archivo de texto, que es guardado en la carpeta del programa</p>

<p>size(800, 400); //Creamos una ventana de 800 píxeles de anchura por 600 píxeles de altura 
}</p>

<p>void setup()
{
port.write("p"); //Envia una "p" para que el Arduino lea la presión
}</p>

<p>{
  //Recibir datos presión del Arduino 
  if(port.available() &gt; 0) // si hay algún dato disponible en el puerto
   {
     valorP=port.read();//Lee el dato y lo almacena en la variable "valorP"
   }</p>

<p>//Visualizamos la presión con un texto
   text("Presión =",390,200);
   text(valorP, 520, 200);
   text(" hPa",547,200);</p>

<p>//Escribimos los datos de la presión con el tiempo (h/m/s) en el archivo de texto
   output.print(valorP + " hPa     ");
   output.print(hour( )+":");
   output.print(minute( )+":");
   output.println(second( ));
   output.println("");</p>

<p>}</p>

<p>{
port.write("h"); //Envia una "h" para que el  Arduino lea la humedad y la temperatura</p>

<p>}</p>

<p>void draw()</p>

<p>{
  //Recibir datos de Temperatura y Humedad del Arduino 
  if(port.available() &gt; 0) // si hay algún dato disponible en el puerto</p>

<p>{</p>

<p>//Leemos hasta que se encuentre un espacio y guardamos lo leido en Data
  Data = port.readStringUntil(" ");
   //buscamos la posición del espacio que separa 
  //los dos valores y guardamos la posición en index
  index = Data.indexOf(" ");</p>

<p>//almacenamos la primera parte del texto en valorH
  valorH= Data.substring(0,index);
  //Almacenamos la segunda parte en valorT
  valorT= Data.substring(index+1,Data.length());
}
 }
   {
     valor=port.read();//Lee el dato y lo almacena en la variable "valorH" 
   }
   //Visualizamos la humedad y la temperatura con un texto
   text("Humedad = ", 390, 300);
  [color=green] text(valorH, 520, 300);
   text(" % ", 547, 300);
   text("Temperatura = ", 630, 300);
   text(valorT, 520, 547);
   text("  ºC  ", 547, 300);[/color]
 }
      {
   //Escribimos los datos de la temperatura y la humedad con el tiempo (h/m/s) en el archivo de texto
   output.print(valorHT + "   %     ºC     ");
   output.print(hour( )+":");
   output.print(minute( )+":");
   output.println(second( ));
   output.println("");</p>

<p>}</p>

<p>void keyPressed() //Cuando se pulsa una tecla
{</p>

<p>}
  {
  //Pulsar la tecla E para salir del programa
  if(key=='e' || key=='E')</p>

<p>{
    output.flush(); // Escribe los datos restantes en el archivo
    output.close(); // Final del archivo
    exit();//Salimos del programa
  }
}</p>

<p>Pero no se si está bien porque me da varios errores.  Si alguien pudiese echar un vistazo a ver qué está mal, me sería de gran ayuda.  Muchas gracias.</p>
]]></description>
   </item>
   <item>
      <title>How to make sketch look through string + make a println showing number of occurrences of each vowel?</title>
      <link>https://forum.processing.org/two/discussion/13750/how-to-make-sketch-look-through-string-make-a-println-showing-number-of-occurrences-of-each-vowel</link>
      <pubDate>Wed, 02 Dec 2015 21:11:41 +0000</pubDate>
      <dc:creator>TheTurtle413</dc:creator>
      <guid isPermaLink="false">13750@/two/discussions</guid>
      <description><![CDATA[<p>I need to make the sketch search through the string "The unusually quick brown fox jumps over the lazy family dog repeatedly." and make a (println) output report showing the number of occurrences for each vowel (a,e,i,o,u). I made some code, but I got stuck. For example, the println showed 9 for the vowel a even though the vowel a occurs four times in the string. What am I doing wrong? Thanks.</p>

<pre>String sentence = "The unusually quick brown fox jumps over the lazy family dog repeatedly.";
println(sentence.indexOf("a"));
println(sentence.indexOf("e"));
println(sentence.indexOf("i"));
println(sentence.indexOf("o"));
println(sentence.indexOf("u"));
noLoop();</pre>
]]></description>
   </item>
   <item>
      <title>Search strings for words in between a tag?</title>
      <link>https://forum.processing.org/two/discussion/13226/search-strings-for-words-in-between-a-tag</link>
      <pubDate>Sat, 24 Oct 2015 15:05:00 +0000</pubDate>
      <dc:creator>bnjm</dc:creator>
      <guid isPermaLink="false">13226@/two/discussions</guid>
      <description><![CDATA[<p>How can I use Processing to search strings (Text from a webpage) and pull out the words in-between a tag, for example everything between <code>&lt;p&gt; and &lt;/p&gt;</code></p>
]]></description>
   </item>
   <item>
      <title>Question regarding indexOf</title>
      <link>https://forum.processing.org/two/discussion/11350/question-regarding-indexof</link>
      <pubDate>Wed, 17 Jun 2015 00:24:20 +0000</pubDate>
      <dc:creator>iakovos</dc:creator>
      <guid isPermaLink="false">11350@/two/discussions</guid>
      <description><![CDATA[<p>indexOf returns the index position of the first occurrence of a substring, is it possible to return all of the occurrences of a substring (character) in the same way?</p>
]]></description>
   </item>
   <item>
      <title>Separating Net messages</title>
      <link>https://forum.processing.org/two/discussion/10248/separating-net-messages</link>
      <pubDate>Thu, 09 Apr 2015 15:21:29 +0000</pubDate>
      <dc:creator>Attarr</dc:creator>
      <guid isPermaLink="false">10248@/two/discussions</guid>
      <description><![CDATA[<p>Starting to use the Net library and notices that sometimes multiple messages would "stick" together and be read as one message. Ive started using a start and end flag and string indexOf to find complete messages out of the clusters. I was wondering if there is a built in or easier way to do this?</p>

<p>input "start""message1""end""start""message2""end"</p>

<p>output message1
           message2</p>
]]></description>
   </item>
   <item>
      <title>Parsing unusual XML file</title>
      <link>https://forum.processing.org/two/discussion/10016/parsing-unusual-xml-file</link>
      <pubDate>Tue, 24 Mar 2015 21:09:36 +0000</pubDate>
      <dc:creator>copytco</dc:creator>
      <guid isPermaLink="false">10016@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>I am trying to parse a BeerXML file (specification can be found under www.beerxml.com), which is kind of unusual. The structure looks more or less like below.</p>

<pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;RECIPES&gt;
   &lt;RECIPE&gt;
     &lt;NAME&gt;Wiezenbock&lt;/NAME&gt;
     &lt;VERSION&gt;1&lt;/VERSION&gt;
     &lt;TYPE&gt;All Grain&lt;/TYPE&gt;
     &lt;BREWER&gt;Panin&lt;/BREWER&gt;
     &lt;ASST_BREWER&gt;&lt;/ASST_BREWER&gt;
     &lt;BATCH_SIZE&gt;20.0000000&lt;/BATCH_SIZE&gt;
     &lt;BOIL_SIZE&gt;25.3400000&lt;/BOIL_SIZE&gt;
     &lt;BOIL_TIME&gt;70.0000000&lt;/BOIL_TIME&gt;
     &lt;EFFICIENCY&gt;70.0000000&lt;/EFFICIENCY&gt;
     &lt;HOPS&gt;
        &lt;HOP&gt;
        &lt;NAME&gt;Lublin&lt;/NAME&gt;
        &lt;VERSION&gt;1&lt;/VERSION&gt;
        &lt;ORIGIN&gt;Poland&lt;/ORIGIN&gt;
        &lt;ALPHA&gt;5.0000000&lt;/ALPHA&gt;
        &lt;/HOP&gt;
        ...
      &lt;/HOPS&gt;
       ...
   &lt;/RECIPE&gt;
&lt;/RECIPES&gt;
</code></pre>

<p>And so on. Despite wrong encoding (I will take care of this myself), here are many children, while built-in XML parser reads only one parent - "RECIPES" and only one child - "RECIPE". The XML file is automatically generated by BeerSmith software, so I do not have any possibility to modify the output. Is there any way to properly extract e.g. all values of "NAME" for all found "HOP" within "HOPS"?</p>
]]></description>
   </item>
   <item>
      <title>How to use match()</title>
      <link>https://forum.processing.org/two/discussion/8463/how-to-use-match</link>
      <pubDate>Thu, 04 Dec 2014 10:31:32 +0000</pubDate>
      <dc:creator>jaap</dc:creator>
      <guid isPermaLink="false">8463@/two/discussions</guid>
      <description><![CDATA[<p>In processing.js i used the following code to find a character position within the string scale:
<code>
int whatKey()
  {
    int i;
    for (i=0; i&lt;EOS; i++)
      {
        if (scale.charCodeAt(i)==key) return i;<br />
      }
    return -1;
  }
</code>
How can I do this in p5.js? I tried with match() but don't know the syntax.</p>
]]></description>
   </item>
   <item>
      <title>println if a string contains a certain character only once</title>
      <link>https://forum.processing.org/two/discussion/8066/println-if-a-string-contains-a-certain-character-only-once</link>
      <pubDate>Tue, 11 Nov 2014 07:03:16 +0000</pubDate>
      <dc:creator>anderssonx</dc:creator>
      <guid isPermaLink="false">8066@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to code a program to check a string for a certain character and if it's found once (but not less or more than one)in the string i want to print a line to the command box.</p>

<p>How can i achieve this?</p>
]]></description>
   </item>
   </channel>
</rss>