Read VDIP feedback

I am trying to read the feedback from VDIP with my mega in order to react to upcoming error messages.

I used the arduino playground code and modified it with PSTRING to put the serial feedback into a container. But compiling it gives an error all the time:
In function ‘void loop()’:
error: ‘mess’ was not declared in this scop

Does anyone have an idea what I did wrong?

#include <PString.h>
int incomingByte=0;
int fileNumber=1;
int noOfChars;
long int valToWrite;
char activityToLog;
long int x;
long int startLogTime = 0;
int vdippower = 52;                 // LED connected to digital pin 13
char vdipreturnmassage;
char vdipreturnmessagebuffer[40];

void setup()
  pinMode(vdippower, OUTPUT);
  digitalWrite(vdippower, HIGH);
  Serial1.print(13, BYTE);


void loop()
  int incoming = 0;
  if (Serial.available()) {
    incoming =;

  if (incoming =='1'){
    Serial1.print(13, BYTE);
    incoming = 0;

  if (incoming=='2'){
    Serial1.print("OPW test1");                  // open to write creates a file - named
    //Serial1.print("nochmaltest");                  // LOG%1.TXT first time round - .TXT is for the computer
    Serial1.print(".TXT");                      // I have used the % sign in the name so I can 
    //search the disk for log files that it has created 
    //so as not to overwrite any that may be on already
    Serial1.print(13, BYTE);                    // return character

    for (int i=0; i <= 5; i++){
      valToWrite=millis() - startLogTime; // time since we started logging
      x=valToWrite;                       // need to copy valToWrite as getting no of characters will consume it
      while (x>= 10){                     // counts the characters in the number
        noOfChars++;                      // thanks to D Mellis for this bit
      noOfChars +=1;                      //add 2 to the num as will also write the letter P and a return character
      Serial1.print("WRF ");               //write to file (file needs to have been opened to write first)
      Serial1.print(noOfChars);            //needs to then be told how many characters will be written
      Serial1.print(13, BYTE);             //return to say command is finished
      Serial1.print(13, BYTE);             //write a return to the contents of the file (so each entry appears on a new line)

    Serial1.print("CLF test1");     // it closes the file
    //Serial1.print("nochmaltest");     // LOG%1.TXT
    Serial1.print(13, BYTE);       // return character

  if (Serial1.available()) {
    PString mess(vdipreturnmessagebuffer, sizeof(vdipreturnmessagebuffer));
    mess += ((char);

[glow]if (mess == "Ver 03.66VDAPF On-Line:Device Detected P2No Upgrade" {[/glow]


It looks like mess is defined within the if statement above. Try moving the definition out like this.

  PString mess;
  if (Serial1.available()) {
    mess(vdipreturnmessagebuffer, sizeof(vdipreturnmessagebuffer));
    mess += ((char);

  if (mess == "Ver 03.66VDAPF On-Line:Device Detected P2No Upgrade" {