<?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 #string - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23string</link>
      <pubDate>Sun, 08 Aug 2021 19:20:05 +0000</pubDate>
         <description>Tagged with #string - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23string/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How many ways to create A-Z alphabet table on the sketch</title>
      <link>https://forum.processing.org/two/discussion/13658/how-many-ways-to-create-a-z-alphabet-table-on-the-sketch</link>
      <pubDate>Wed, 25 Nov 2015 22:47:44 +0000</pubDate>
      <dc:creator>boomp</dc:creator>
      <guid isPermaLink="false">13658@/two/discussions</guid>
      <description><![CDATA[<p>I would like to create data visualization to display how many letters was repeted from the "String" I already had on A-Z table.</p>

<p>But first I would like to <b>create A-Z alphabet table on my sketch.</b></p>

<p>As far as I know, 
I can make each alphabet in <b>svg.</b> and then import them and rearrange each of them on my sketch.</p>

<p>But I saw the on the processing/example/Typography/Letters 
which is already arranged all the alphabets. 
<img src="https://forum.processing.org/two/uploads/imageupload/438/E11CR77FNZAV.png" alt="Screen Shot 2015-11-25 at 23.33.43" title="Screen Shot 2015-11-25 at 23.33.43" /></p>

<p>this is the default code:</p>

<pre lang="javascript">/**
 * Letters. 
 * 
 * Draws letters to the screen. This requires loading a font, 
 * setting the font, and then drawing the letters.
 */

PFont f;

void setup() {
  size(640, 360);
  background(0);

  // Create the font
  printArray(PFont.list());
  f = createFont("Georgia", 24);
  textFont(f);
  textAlign(CENTER, CENTER);
} 

void draw() {
  background(0);

  // Set the left and top margin
  int margin = 10;
  translate(margin*4, margin*4);

  int gap = 46;
  int counter = 35;
  
  for (int y = 0; y &lt; height-gap; y += gap) {
    for (int x = 0; x &lt; width-gap; x += gap) {

      char letter = char(counter);
      
      if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U') {
        fill(255, 204, 0);
      } 
      else {
        fill(255);
      }

      // Draw the letter to the screen
      text(letter, x, y);

      // Increment the counter
      counter++;
    }
  }
}
 </pre>

<p>but I don't know how to edit this file. 
<br />1. I would like to know if it's possible to make it shows only A-Z on the sketch? Because as far as I try change to larger size in setup() it shows more of the other letters as if the size is only to frame them. 
<br />2. Is it possible to play with these alphabet or actually it's for display. </p>

<p><br /><i>another amateur question, please be patience with me.</i></p>
]]></description>
   </item>
   <item>
      <title>using replace() in a text file for changing words - not char sequences</title>
      <link>https://forum.processing.org/two/discussion/13697/using-replace-in-a-text-file-for-changing-words-not-char-sequences</link>
      <pubDate>Sun, 29 Nov 2015 18:39:54 +0000</pubDate>
      <dc:creator>akenaton</dc:creator>
      <guid isPermaLink="false">13697@/two/discussions</guid>
      <description><![CDATA[<p>i have a text file. I want to change some words. I thought it was easy to do using replace(). Which works but too much, i mean that it changes all occurences of char sequence, and sometimes changes words sometimes changes only char sequence into a word. In order to be much clear see the example (i want to change only the word "pur")===</p>

<pre><code>String s;

void setup(){
    size(400,200);
    background(0);
    fill(255);
    textSize(24);

    s= "pur pureté purify";
    String dep = "pur";
    s = s.replace(dep, "kleen"); 
    text(s, 100,100);
    ///displays: kleen kleeneté, kleenify.....
}
</code></pre>

<p>Solution (as for me!!!) could be to test wether next char is ' ' but i don't see how to do that in a simple way, knowing that the the real text file is 100 pages long. Another one to write String dep = "pur " instead of "pur", but with the real text this changes the whole textAlign, + it works only if the word is the first one. Another solution:: to make an arrayList, then get &amp;&amp;  remove the old word, then add the new one, then transform my array in a string.... and it probably works but seems really stupid!!!</p>

<p>Any idea???
thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>Display last sentence of inputted text.</title>
      <link>https://forum.processing.org/two/discussion/11114/display-last-sentence-of-inputted-text</link>
      <pubDate>Tue, 02 Jun 2015 13:49:25 +0000</pubDate>
      <dc:creator>Vaun</dc:creator>
      <guid isPermaLink="false">11114@/two/discussions</guid>
      <description><![CDATA[<p>HI folks,</p>

<p>I have a processing sketch which uses text inputted by the user via keyboard and then cycles through 3 screens (screen 0, 1 and 2). What I want is that when it returns to screen one, the last sentence of the previous user's text displays and the next user types after it (sort of like a chain story).</p>

<p>String myText = "Your story..."; //text that displays initially on Screen 0
String yourText = ""; // Variable to store text currently being typed
String savedText = ""; // Variable to store saved text when RETURN is hit</p>

<p>Hitting RETURN advances the sketch to the next screen where text is manipulated and also saved out a .txt file</p>

<p>At the end of Screen 2, I want it to return to Screen 0 - but instead of displaying 'myText', I want it to display the last sentence of 'yourText' or 'savedText' (which are the same text).</p>

<p>I think I would have to search for the last occurrance of a period+space, then make yourText = whatever text appears after that period+space.</p>

<p>I know 'search' can locate the idex of the first instance of particular characters, but not sure how I would get it to locate the last instance. Is there a way I can get it to search the string from end to beginning, instead of beginning to end...or am I making this too complicated? Any help, gratefully accepted.</p>

<p>ON a separate note, since I changed the keyPressed to RETURN from CONTROL, all my characters are displaying twice. Any advice on that is welcome too.</p>

<p>Text input part of code below:</p>

<pre><code>void keyPressed() {
  if (keyCode == BACKSPACE) {
    if (yourText.length() &gt; 0) {
      yourText = yourText.substring(0, yourText.length()-1);
    }
      } else if (keyCode == DELETE) {
        yourText = "";
      } else if (keyCode != SHIFT &amp;&amp; keyCode != CONTROL &amp;&amp; keyCode != RETURN &amp;&amp; keyCode != ENTER &amp;&amp; keyCode != ALT) {
        myText = "";
        yourText = yourText + key;
      }

  // If the Return key is pressed save the String and write it to text file
    //if (key == CODED) 
    //{
    if (key == RETURN )  {
      savedText = yourText;
      textFile = createWriter("stories/"+timestamp()+".txt");
      textFile.println(savedText);
      textFile.flush();
      textFile.close();
      time = millis();//store the current time
      rect (0,0,width, height); //PROBLEM sometimes visible when screen is switched.
      noStroke ();
      currentScreen++;
  if (currentScreen &gt; 2) { currentScreen = 0; } //switches to next screen

  } 

 else {
      // Otherwise, concatenate the String
      // Each character typed by the user is added to the end of the String variable.
      yourText = yourText + key;
    }
  //}
}
</code></pre>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Display Upside Down Text</title>
      <link>https://forum.processing.org/two/discussion/10237/display-upside-down-text</link>
      <pubDate>Wed, 08 Apr 2015 10:27:54 +0000</pubDate>
      <dc:creator>knowyourenemy</dc:creator>
      <guid isPermaLink="false">10237@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone, 
How to display text or strings upside down in processing (android mode)? This is so that people on both sides of the screen can have text facing them.</p>
]]></description>
   </item>
   <item>
      <title>characters in an array with repetition number</title>
      <link>https://forum.processing.org/two/discussion/10202/characters-in-an-array-with-repetition-number</link>
      <pubDate>Mon, 06 Apr 2015 04:51:10 +0000</pubDate>
      <dc:creator>lilispi</dc:creator>
      <guid isPermaLink="false">10202@/two/discussions</guid>
      <description><![CDATA[<p>Hello! i need help. I'm reading a file.txt which data store them in an array. Now I want to read the file and count how many times each character is repeated and finally print the list of characters with the number of times this re repeats. Someone can tell me how could.</p>
]]></description>
   </item>
   <item>
      <title>A string is too big for a rect, how can I draw the rest of it underneath?</title>
      <link>https://forum.processing.org/two/discussion/9642/a-string-is-too-big-for-a-rect-how-can-i-draw-the-rest-of-it-underneath</link>
      <pubDate>Sun, 01 Mar 2015 17:36:19 +0000</pubDate>
      <dc:creator>devonrevenge</dc:creator>
      <guid isPermaLink="false">9642@/two/discussions</guid>
      <description><![CDATA[<p>I was trying to work out how to use text width to work out if its larger than the box, I was going to then add a word to another string thats going to be drawn underneath, re measure, and if the string is too long append the next word to the beggining of the string beneath else it fits...</p>

<p>But it occured to me there might be a function allready for this, have to ask</p>
]]></description>
   </item>
   <item>
      <title>How Do I Test An Output of Strings For a Certain Character That Shows Up Several Times In A Row</title>
      <link>https://forum.processing.org/two/discussion/9512/how-do-i-test-an-output-of-strings-for-a-certain-character-that-shows-up-several-times-in-a-row</link>
      <pubDate>Fri, 20 Feb 2015 17:16:37 +0000</pubDate>
      <dc:creator>sejjady</dc:creator>
      <guid isPermaLink="false">9512@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
I'm fairly new to processing and programming in general. I have an Arduino that is sending numbers from 0 to about 20000 to processing. I am using a program that loops a println of a string that reads and updates the input from the Arduino.</p>

<p><code>void draw() {
  while (myPort.available() &gt; 0) {
    String inBuffer = myPort.readString();   
    if (inBuffer != null) {
      println(inBuffer);
    }</code></p>

<p>This will continually print numbers based on the input from the Arduino, inBuffer being string that changes with the Arduino output. What I want to do is have the program look to see if the numbers 0 or 1 appear twice in a row and if they do, trigger one set of code, otherwise trigger another set of code.</p>
]]></description>
   </item>
   <item>
      <title>Empty an array, NullPointerException</title>
      <link>https://forum.processing.org/two/discussion/9015/empty-an-array-nullpointerexception</link>
      <pubDate>Tue, 13 Jan 2015 07:16:00 +0000</pubDate>
      <dc:creator>Dr_Quark</dc:creator>
      <guid isPermaLink="false">9015@/two/discussions</guid>
      <description><![CDATA[<p>Newbie to processing, using Arduino IDE for 18 months.<br />
Win7, Processing 2.2.1</p>

<p>My Arduino central heat controller sends a serial string of data once per minute. My laptop, running a processing sketch, receives this string, appends it to a string array, and every so often saves the array to a file on disk (the objective is to save it once a day, which is just under 1500 lines, but in the test version I'm saving the file with only 4 lines).</p>

<p>My problem is that once the array is saved, I need to "empty" it. Otherwise, the code <code>dataArray = append(dataArray, dataLine);</code> will continue to grow the array, rather than start over refilling it. I say "empty" because I don't need to collapse the array and recover memory, I just need the array pointer to be reset to the first line. In the normal course of events, all the data in the array would be overwritten with new data. Each day the array will be similar in size (plus or minus one or two lines) and any extraneous line will be obvious because each line is time tagged. The data is eventually plotted in Excel. Here's the full code:</p>

<pre><code>import processing.serial.*;
int n;
int today ;
int yesterday ;
String filename ;
String dataLine = "" ;
String[] dataArray = {};
Serial dataPort ;
// ----------------------------------------------------
void setup() {
  // Open whatever port you're using.
  String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
  dataPort = new Serial(this, portName, 9600); 
  n = 0 ;
  //  filename = nf(year(),4,0)+nf(month(),2,0)+nf(day(),2,0)+'_'+nf(hour(),2,0)+nf(minute(),2,0)+".CSV" ;
  //   println(filename) ;
  println(Serial.list()) ;
  yesterday = day() ;
  }  
// -----------------------------------------------------  
void draw() {
  if ( dataPort.available() &gt; 0) {  // If data is available
    n=n+1 ;
    dataLine = dataPort.readStringUntil('\n');  // read it and store it in dataLine
    if(dataLine != null) {
     dataLine = trim(dataLine) ;  // remove carriage return at end of line
     dataLine = nf(hour(),2,0)+':'+nf(minute(),2,0)+':'+nf(second(),2,0)+','+dataLine ;
     dataArray = append(dataArray, dataLine);
     println(dataLine); //print it out in the console
    } }
  today = day() ; 
  //if(today != yesterday) {
    if(n&gt;3) {  // the loop counter "n" is used only for testing
    println("saving to file") ;
    filename = nf(year(),2,0)+nf(month(),2,0)+nf(yesterday,2,0)+"_"+nf(second(),2,0)+".CSV" ;     
    println(filename) ;
    yesterday = today ;
    saveStrings(filename, dataArray) ; 
    dataArray = null ;
    dataArray[0] = "" ;
    n=0 ; }
  delay(6000) ;
}
</code></pre>

<p>The output in the console is as expected the first time through:</p>

<pre><code>COM41
23:07:29,11,1,65.97,65.64,0.00,0.00,66.20,65.75,65.97,65.64
23:08:29,01,1,66.09,65.64,0.00,0.00,66.31,65.86,65.86,65.75
23:09:35,61,1,66.09,65.64,0.00,0.00,66.31,65.75,65.97,65.64
23:10:29,41,1,65.97,65.64,0.00,0.00,66.20,65.75,65.97,65.64
saving to file
20150112_29.CSV
</code></pre>

<p>I've used these lines from other forum recommendations to try and empty the dataArray, but I get the NullPointerException either in the second line or elsewhere in the sketch:</p>

<pre><code>dataArray = null ;
dataArray[0] = "" ;
</code></pre>

<p>Thanks for any insight.
Dr Quark</p>
]]></description>
   </item>
   <item>
      <title>How can I organize strings by their content?</title>
      <link>https://forum.processing.org/two/discussion/8578/how-can-i-organize-strings-by-their-content</link>
      <pubDate>Wed, 10 Dec 2014 08:01:21 +0000</pubDate>
      <dc:creator>Alrro</dc:creator>
      <guid isPermaLink="false">8578@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I have a .txt file with strings. And, you see that there are words that start and end with [ and ] respectively. My question is, how can I organize strings by these words. Imagine, the first word is [duck], how can I make that all strings from that and the next [] word are related in a Hashmap?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Serial connection + working with strings</title>
      <link>https://forum.processing.org/two/discussion/8304/serial-connection-working-with-strings</link>
      <pubDate>Sun, 23 Nov 2014 09:39:51 +0000</pubDate>
      <dc:creator>strinda</dc:creator>
      <guid isPermaLink="false">8304@/two/discussions</guid>
      <description><![CDATA[<p>I want to get 5 numbers from Arduino
at the moment, the Arduino program looks like this</p>

<p>void setup() {
  Serial.begin(9600);
}</p>

<p>void loop() {
Serial.println ("45 56 56 65");
}</p>

<p>This is my Processing programm, and it doesn't work for some reason</p>

<p>import processing.serial.*;</p>

<p>int data [];</p>

<p>Serial myPort;
String val;</p>

<p>void setup () {
size (400,400);</p>

<p>String portName = Serial.list()[0];
myPort = new Serial (this, portName, 9600);
myPort.bufferUntil('\n');
}</p>

<p>void draw () {</p>

<p>}</p>

<p>void serialEvent (Serial myPort) 
{
val = myPort.readStringUntil('\n');
val = val.substring(0, val.indexOf("\n"));<br />
data = int(split(val, ' '));
}</p>

<p>Thank you for your help,
Alex</p>
]]></description>
   </item>
   </channel>
</rss>