Copy/paste to code box

I like the way the new code box copy and paste works. OK, I don't :cry:

/*--------------------------------------------------------------[color=#222222][/color]
  Program:      eth_websrv_SD[color=#222222][/color]
[color=#222222][/color]
  Description:  Arduino web server that serves up a basic web[color=#222222][/color]
                page. The web page is stored on the SD card.[color=#222222][/color]
  [color=#222222][/color]
  Hardware:     Arduino Uno and official Arduino Ethernet[color=#222222][/color]
                shield. Should work with other Arduinos and[color=#222222][/color]
                compatible Ethernet shields.[color=#222222][/color]
                2Gb micro SD card formatted FAT16[color=#222222][/color]
                [color=#222222][/color]
  Software:     Developed using Arduino 1.0.3 software[color=#222222][/color]
                Should be compatible with Arduino 1.0 +[color=#222222][/color]
                SD card contains web page called index.htm[color=#222222][/color]
  [color=#222222][/color]
  References:   - WebServer example by David A. Mellis and [color=#222222][/color]
                  modified by Tom Igoe[color=#222222][/color]
                - SD card examples by David A. Mellis and[color=#222222][/color]
                  Tom Igoe[color=#222222][/color]
                - Ethernet library documentation:[color=#222222][/color]
                  http://arduino.cc/en/Reference/Ethernet[color=#222222][/color]
                - SD Card library documentation:[color=#222222][/color]
                  http://arduino.cc/en/Reference/SD[color=#222222][/color]
[color=#222222][/color]
  Date:         10 January 2013[color=#222222][/color]
 [color=#222222][/color]
  Author:       W.A. Smith, http://startingelectronics.com[color=#222222][/color]
--------------------------------------------------------------*/[color=#222222][/color]
[color=#222222][/color]
#include <SPI.h>[color=#222222][/color]
#include <Ethernet.h>[color=#222222][/color]
#include <SD.h>[color=#222222][/color]
[color=#222222][/color]
// MAC address from Ethernet shield sticker under board[color=#222222][/color]
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };[color=#222222][/color]
IPAddress ip(10, 10, 1, 222); // IP address, may need to change depending on network[color=#222222][/color]
EthernetServer server(80);  // create a server at port 80[color=#222222][/color]
[color=#222222][/color]
File webFile;[color=#222222][/color]
[color=#222222][/color]
void setup()[color=#222222][/color]
{[color=#222222][/color]
    Ethernet.begin(mac, ip);  // initialize Ethernet device[color=#222222][/color]
    server.begin();           // start to listen for clients[color=#222222][/color]
    Serial.begin(9600);       // for debugging[color=#222222][/color]
    [color=#222222][/color]
    // initialize SD card[color=#222222][/color]
    Serial.println("Initializing SD card...");[color=#222222][/color]
    if (!SD.begin(4)) {[color=#222222][/color]
        Serial.println("ERROR - SD card initialization failed!");[color=#222222][/color]
        return;    // init failed[color=#222222][/color]
    }[color=#222222][/color]
    Serial.println("SUCCESS - SD card initialized.");[color=#222222][/color]
    // check for index.htm file[color=#222222][/color]
    if (!SD.exists("index.htm")) {[color=#222222][/color]
        Serial.println("ERROR - Can't find index.htm file!");[color=#222222][/color]
        return;  // can't find index file[color=#222222][/color]
    }[color=#222222][/color]
    Serial.println("SUCCESS - Found index.htm file.");[color=#222222][/color]
}[color=#222222][/color]
[color=#222222][/color]
void loop()[color=#222222][/color]
{[color=#222222][/color]
  [color=#222222][/color]
String requestString = "" ;//String to store chars[color=#222222][/color]
    EthernetClient client = server.available();  // try to get client[color=#222222][/color]
[color=#222222][/color]
    if (client) {  // got client?[color=#222222][/color]
        boolean currentLineIsBlank = true;[color=#222222][/color]
        while (client.connected()) {[color=#222222][/color]
            if (client.available()) {   // client data available to read[color=#222222][/color]
                char c = client.read(); // read 1 byte (character) from client[color=#222222][/color]
                // last line of client request is blank and ends with \n[color=#222222][/color]
                // respond to client only after last line received[color=#222222][/color]
                requestString = requestString + c;[color=#222222][/color]
                if (c == '\n' && currentLineIsBlank) [color=#222222][/color]
                   {if (requestString.indexOf("dygraph")>0)[color=#222222][/color]
                    {// send a standard http response header[color=#222222][/color]
                    client.println("HTTP/1.1 200 OK");[color=#222222][/color]
                    client.println("Content-Type: application/javascript");[color=#222222][/color]
                    client.println("Connection: close");[color=#222222][/color]
                    client.println();[color=#222222][/color]
                    webFile = SD.open("dygraph.js");        // open web page file[color=#222222][/color]
                    if (webFile) {[color=#222222][/color]
                        while(webFile.available()) {[color=#222222][/color]
                            client.write(webFile.read()); // send web page to client[color=#222222][/color]
                        }[color=#222222][/color]
                        webFile.close();[color=#222222][/color]
                    } [color=#222222][/color]
                else[color=#222222][/color]
                    {[color=#222222][/color]
                    // send a standard http response header[color=#222222][/color]
                    client.println("HTTP/1.1 200 OK");[color=#222222][/color]
                    client.println("Content-Type: text/html");[color=#222222][/color]
                    client.println("Connection: close");[color=#222222][/color]
                    client.println();[color=#222222][/color]
                    // send web page[color=#222222][/color]
                    webFile = SD.open("index.htm");        // open web page file[color=#222222][/color]
                    if (webFile) [color=#222222][/color]
                        while(webFile.available()) [color=#222222][/color]
                            client.write(webFile.read()); // send web page to client[color=#222222][/color]
                        [color=#222222][/color]
                        webFile.close();[color=#222222][/color]
                    }[color=#222222][/color]
                   }[color=#222222][/color]
                 break;[color=#222222][/color]
                }[color=#222222][/color]
                [color=#222222][/color]
                [color=#222222][/color]
                // every line of text received from the client ends with \r\n[color=#222222][/color]
                if (c == '\n') {[color=#222222][/color]
                    // last character on line of received text[color=#222222][/color]
                    // starting new line with next character read[color=#222222][/color]
                    currentLineIsBlank = true;[color=#222222][/color]
                } [color=#222222][/color]
                else if (c != '\r') {[color=#222222][/color]
                    // a text character was received from client[color=#222222][/color]
                    currentLineIsBlank = false;[color=#222222][/color]
                }[color=#222222][/color]
            } // end if (client.available())[color=#222222][/color]
        } // end while (client.connected())[color=#222222][/color]
        delay(1);      // give the web browser time to receive the data[color=#222222][/color]
        client.stop(); // close the connection[color=#222222][/color]
    } // end if (client)[color=#222222][/color]
}

From the IDE or a forum feature?

The code above was copied from a post in Networking and pasted into a quick reply box.

I tried it several time earlier before posting the code above, and it did the same as above The same test now works ok. Got me. ??

Turn off the rich text mode and this problem goes away. However the fact that it happens at all would seem to indicate that the rich text mode is a bit of a failure.

I copied this code from a post from a user wanting help. What do you think? Can you copy this code and paste it into the IDE? I can't post this as a response, and I don't want to go through it removing all the color stuff.

#include <SPI.h>[color=#222222][/color]
#include <Ethernet.h>[color=#222222][/color]
[color=#222222][/color]
byte mac[] = { 0x16, 0x9E, 0x1E, 0xCB, 0x72, 0x45 };[color=#222222][/color]
byte ip[] = { 192,168,0,111 };[color=#222222][/color]
byte gateway[] = { 192,168,0,1 };[color=#222222][/color]
byte subnet[] = { 255,255,255,0 };[color=#222222][/color]
byte server[] = { 24,220,112,46 };[color=#222222][/color]
[color=#222222][/color]
// initialize the library instance:[color=#222222][/color]
EthernetClient client;[color=#222222][/color]
[color=#222222][/color]
char serverName[] = "api.openweathermap.org";[color=#222222][/color]
[color=#222222][/color]
const int requestInterval = 20000;  // delay between requests[color=#222222][/color]
long lastAttemptTime = 0;   // last time you connected to the server, in milliseconds[color=#222222][/color]
[color=#222222][/color]
String json = "";   // string to hold the text from server[color=#222222][/color]
String weather = "";    // string to hold JSON object[color=#222222][/color]
[color=#222222][/color]
[color=#222222][/color]
void setup() {[color=#222222][/color]
  [color=#222222][/color]
  // reserve space for the strings:[color=#222222][/color]
  json.reserve(256);[color=#222222][/color]
[color=#222222][/color]
  Serial.begin(9600);[color=#222222][/color]
  [color=#222222][/color]
  // disable SD card if one in the slot[color=#222222][/color]
  pinMode(4,OUTPUT);[color=#222222][/color]
  digitalWrite(4,HIGH);[color=#222222][/color]
[color=#222222][/color]
  [color=#222222][/color]
  Serial.println("Connecting...");[color=#222222][/color]
  [color=#222222][/color]
  // attempt a DHCP connection:[color=#222222][/color]
  if (!Ethernet.begin(mac)) {[color=#222222][/color]
    Serial.println("First Connection Failed, trying with IP and Gateway");[color=#222222][/color]
    // if DHCP fails, start with a hard-coded address:[color=#222222][/color]
    [color=#222222][/color]
      analogWrite(redPin, 255);[color=#222222][/color]
      analogWrite(bluePin, 0);[color=#222222][/color]
      analogWrite(greenPin, 0);[color=#222222][/color]
    [color=#222222][/color]
      Ethernet.begin(mac,ip,gateway);[color=#222222][/color]
      [color=#222222][/color]
      Serial.println(Ethernet.localIP());[color=#222222][/color]
      Serial.println("Connecting...");[color=#222222][/color]
      [color=#222222][/color]
      if (client.connect(serverName,80)) {[color=#222222][/color]
        Serial.println("Connected");[color=#222222][/color]
        // Make a HTTP request:[color=#222222][/color]
      }[color=#222222][/color]
      else {[color=#222222][/color]
        Serial.println("Connection failed");[color=#222222][/color]
      }[color=#222222][/color]
  } else {[color=#222222][/color]
    Serial.println("Connected!");  [color=#222222][/color]
  };[color=#222222][/color]
  [color=#222222][/color]
  // connect to server:[color=#222222][/color]
  connectToServer();[color=#222222][/color]
}[color=#222222][/color]
[color=#222222][/color]
[color=#222222][/color]
[color=#222222][/color]
void loop(){[color=#222222][/color]
  if (client.connected()) {[color=#222222][/color]
    if (client.available()) {[color=#222222][/color]
      // read incoming bytes:[color=#222222][/color]
      char inChar = client.read();[color=#222222][/color]
      [color=#222222][/color]
      json += inChar;[color=#222222][/color]
      [color=#222222][/color]
      if (inChar == '\n') {[color=#222222][/color]
        Serial.println(json);[color=#222222][/color]
        if ( json.startsWith("{") ) {[color=#222222][/color]
          weather = json;[color=#222222][/color]
          Serial.print("JSON: ");[color=#222222][/color]
          Serial.println(weather);[color=#222222][/color]
        };[color=#222222][/color]
        json = "";[color=#222222][/color]
      } [color=#222222][/color]
      [color=#222222][/color]
  } else if (millis() - lastAttemptTime > requestInterval) {[color=#222222][/color]
    Serial.println("Server disconnected; reconnecting");[color=#222222][/color]
    connectToServer();[color=#222222][/color]
  } else {[color=#222222][/color]
    Serial.println("Waiting to retry");[color=#222222][/color]
  };[color=#222222][/color]
};[color=#222222][/color]
[color=#222222][/color]
[color=#222222][/color]
[color=#222222][/color]
void connectToServer() {[color=#222222][/color]
  // attempt to connect, and wait a millisecond:[color=#222222][/color]
  Serial.println("Connecting to server...");[color=#222222][/color]
  if (client.connect(serverName, 80)) {[color=#222222][/color]
    Serial.println("Making HTTP request...");[color=#222222][/color]
[color=#222222][/color]
    client.println("GET /data/2.5/weather?id=5231851&APPID=MYAPPID HTTP/1.1");[color=#222222][/color]
    client.println("HOST: api.openweathermap.org");[color=#222222][/color]
    client.println();[color=#222222][/color]
  };[color=#222222][/color]
[color=#222222][/color]
  lastAttemptTime = millis();[color=#222222][/color]
};

Turn on "view source" mode, and then copy and paste it again. You can make that a default in your forum profile.

Where in my forum profile?

Profile -> Forum Settings -> Edit -> Settings -> Look and Layout.

Uncheck "Show WYSIWYG editor on post page by default.".

Thanks. I changed the setting. Now to see how it does.