How compare the Char data which is store on EEPROM

Hi,

I need some help to compare the char data (as I understand).

Below example code store the data on EEPROM and I can read this data with " miTestText->getValue() " function. Successfully print on LCD and serial monitor.

Library reference : GitHub - damogranlabs/dl-menu: A simple one-level settings menu framework for Arduino 16x2 LiquidCrystal display

// text menu item:
#define DLM_ADDR_TESTTEXT 10 // eeprom address of the text item
#define DLM_TEXT_LENGTH 6 // number of characters (will occupy the same number of bytes in EEPROM)
const char miTextLabel[] PROGMEM  = {"Your name"};
// list of allowed characters: the user chooses between those;
// the default string is filled with the first character of this list
const char miTextAllowedChars[] PROGMEM = {"_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,:;+-"};

DLTextMenuItem *miTestText = new DLTextMenuItem(
  &lcd,
  miTextLabel,
  DLM_ADDR_TESTTEXT,
  miTextAllowedChars,
  DLM_TEXT_LENGTH
);

// initialize menu with all the items
DLMenuItem *menuItems[] = {
  miTestInt, miTestFloat, miTestChoice, miTestText, NULL // ACHTUNG, the last entry must be NULL
};

I want to compare this data with specific text which is not working. Like below

    if (miTestText->getValue() == ABCDEF) {
      lcd.setCursor(12, 1);
      lcd.print("Y");
    }

    if (miTestText->getValue() ! =ABCDEF) {    // OR  (miTestText->getValue() == ! ABCDEF) 
      lcd.setCursor(12, 1);
      lcd.print("N");
    }

Strings are enclosed without quotation marks such as "ABCDEF" not just bare letters.

I do not know what getValue() returns, but if it returns a "String" (uppercase S), then you can do a simple equality test (==). If it returns a C/C++ string (lower case 's' which is a nul terminated array of chars), then you need to use strcmp()

Try this:

// memcmp_E function
//
// by J-M-L http://forum.arduino.cc/index.php?topic=584108.msg3978283#msg3978283
// -------------------------
// Takes: a pointer to a RAM address, eeprom address, and length.
// Function compares the data at the two pairs of addresses for
// len elements and returns true/false status of
// comparison.  Since memcmp() is used, if all elements match
// a zero (false) is returned, +- value otherwise.
// Compares:
// char arrays -  if (!memcmp_E(ts2, 111, 5))
//
// bytes -   if (!memcmp_E(&aByte, EEPROM_addr, 1))
//           if (!memcmp_E(aByteArray, 8, nbItemsInaByteArray))  
//
// ints -  
// longs -  

template<typename T>
int memcmp_E(const T* ramStart, int eeprom_start, size_t  len )
{
  int result = 0; // create and initialize return value
  uint8_t sample[sizeof(T)]; // allocate a buffer for EEPROM.get
  for (size_t i = 0; i < len * sizeof(T); i += sizeof(T)) {
    EEPROM.get( eeprom_start + i, sample); // copy EEPROM data out to RAM
    // then use memcmp to do the compare - avoids dealing with endianness
    result = memcmp ( ((uint8_t *) ramStart) + i, (uint8_t *) sample, sizeof(T) );
    if (result) break; // ie. non-zero
  }
  return result;
}

Put it in a header file named MEMCMP_E.h and #include it in your sketch.