Write to SD card not possible (GUISlice) Help needed

Overview of project:
ESP32 with TFT touch display
Wire frame GUI generated by GUISlice

I have 12 GUI elements (text fields), and a value (temperature) is written one by one to each element by pressing a button.

After all elements have a value written to them I would like to save the values to a .txt file on the SD

First of all the values are written to a string like so:

for (int i = 0; i < 12; i++) {
    dataMessage = gslc_ElemGetTxtStr (&m_gui, (textfield[i]));
}

The name of the text file chosen from a listbox (items in listbox are named Log_1.txt to Log_4.txt).

The selected item in the listbox defines the file name like so:

if (nSelId != XLISTBOX_SEL_NONE) {
        gslc_ElemXListboxGetItem(&m_gui, pElemRef, nSelId, logName, MAX_STR);
        data_log = logName;
        dataFile = SD.open(data_log.c_str(), FILE_WRITE);

Here is a bigger picture of whats going on in the sketch:

int counter (-1);
char   logTemp[5];
char   nullVal[5];
char   logName[8];
static char nullnullval[7] = "---.--";
#define SD_CS 10
String dataMessage;
String data_log;
const int chipSelect = 10;
File dataFile;
bool CbBtnCommon(void* pvGui, void *pvElemRef, gslc_teTouch eTouch, int16_t nX, int16_t nY)
{
  // Typecast the parameters to match the GUI and element types
  gslc_tsGui*     pGui     = (gslc_tsGui*)(pvGui);
  gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
  gslc_tsElem*    pElem    = gslc_GetElemFromRef(pGui, pElemRef);
  gslc_tsElemRef* textfield[] = {
    DATA_TEXT_1,
    DATA_TEXT_2,
    DATA_TEXT_3,
    DATA_TEXT_4,
    DATA_TEXT_5,
    DATA_TEXT_6,
    DATA_TEXT_7,
    DATA_TEXT_8,
    DATA_TEXT_9,
    DATA_TEXT_10,
    DATA_TEXT_11,
    DATA_TEXT_12,
  };
  TS_NTC_103 sensor (0.11, 10);
  float Temp (sensor.getTemp(analogRead(36)));
  if ( eTouch == GSLC_TOUCH_UP_IN ) {
    // From the element's ID we can determine which button was pressed.
    switch (pElem->nId) {
      //<Button Enums !Start!>
      case NEXT_DATA_BTN:
        counter++;
        if (counter > 11) {
          counter = 0;
        }
        snprintf(logTemp, MAX_STR, "%.2f", Temp);
        gslc_ElemSetTxtStr(&m_gui, (textfield[counter]) , logTemp);
        break;
      case PREV_DATA_BTN:
        if (counter >= 0)
        {
          snprintf(nullVal, MAX_STR, "%.2f", nullnullval);
          gslc_ElemSetTxtStr(&m_gui, (textfield[counter]) , nullnullval);
          counter --;
        }
        break;
      case RESET_DATA_BTN:
        gslc_SetPageCur(&m_gui, Log_Delete);
        break;
      case SAVE_SD_BTN:
        gslc_SetPageCur(&m_gui, E_PG_POPUP3);
        break;
      case LOG_DEL_Y:
        gslc_SetPageCur(&m_gui, E_PG5);
        for (int i = 0; i < 12; i++) {
          snprintf(nullVal, MAX_STR, "%.2f", nullnullval);
          gslc_ElemSetTxtStr(&m_gui, (textfield[i]) , nullnullval);
        }
        counter = -1;
        break;
      case LOG_DEL_N:
        gslc_SetPageCur(&m_gui, E_PG5);
        break;
      case OPEN_LOG_BTN:
        break;
      case SAVE_LOG_BTN:
      for (int i = 0; i < 12; i++) {
    dataMessage = gslc_ElemGetTxtStr (&m_gui, (textfield[i]));
     
       if (dataFile) {
    dataFile.println(dataMessage.c_str());
    dataFile.close();
    Serial.println(dataMessage.c_str());
  }
  
  else {
    Serial.println("error opening log file");
  }
  }

      
        break;
      case CLOSE_LOG_PUP:
        gslc_SetPageCur(&m_gui, E_PG5);
        break;
      //<Button Enums !End!>
      default:
        break;
    }
  }
  return true;
}
bool CbListbox(void* pvGui, void* pvElemRef, int16_t nSelId)
{
  gslc_tsGui*     pGui     = (gslc_tsGui*)(pvGui);
  gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
  gslc_tsElem*    pElem    = gslc_GetElemFromRef(pGui, pElemRef);
  if (pElemRef == NULL) {
    return false;
  }
  // From the element's ID we can determine which listbox was active.
  switch (pElem->nId) {
    //<Listbox Enums !Start!>
    case E_ELEM_LISTBOX1:
      if (nSelId != XLISTBOX_SEL_NONE) {
        gslc_ElemXListboxGetItem(&m_gui, pElemRef, nSelId, logName, MAX_STR);
        data_log = logName;
        dataFile = SD.open(data_log.c_str(), FILE_WRITE);
        Serial.print (data_log);
      }
      break;
    //<Listbox Enums !End!>
    default:
      break;
  }
  return true;
}

Unfortunately I cant get it working properly, I can write the values to the text fields, and I can print everything to the serial monitor , but I just cant seem to get any files written to the SD card.

I was hoping someone might be able to give me some pointers.
It would be much appreciated.

tiretool.zip (7.48 KB)

This appears to mostly duplicate the question in the Project Guidance forum, so it might be better to continue the discussion there (where I have provided a followup):

https://forum.arduino.cc/index.php?topic=716684.0

Why the new post?