diff --git a/ExternData/Resources/C-Sources/ED_INIFile.c b/ExternData/Resources/C-Sources/ED_INIFile.c index 4287425a..3e499119 100644 --- a/ExternData/Resources/C-Sources/ED_INIFile.c +++ b/ExternData/Resources/C-Sources/ED_INIFile.c @@ -160,98 +160,128 @@ void ED_destroyINI(void* _ini) } } -double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section) +double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section, int* exist) { double ret = 0.; INIFile* ini = (INIFile*)_ini; + *exist = 1; if (ini != NULL) { INISection* _section = findSection(ini, section); if (_section != NULL) { INIPair* pair = findKey(_section, varName); if (pair != NULL) { - if (ED_strtod(pair->value, ini->loc, &ret)) { - ModelicaFormatError("Cannot read double value \"%s\" from file \"%s\"\n", - pair->value, ini->fileName); + if (NULL != pair->value) { + if (ED_strtod(pair->value, ini->loc, &ret)) { + ModelicaFormatError("Cannot read double value \"%s\" from file \"%s\"\n", + pair->value, ini->fileName); + } + } + else { + ModelicaFormatError("Cannot read value for key \"%s\" from file \"%s\"\n", + varName, ini->fileName); + *exist = 0; } } else { - ModelicaFormatError("Cannot read key \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read key \"%s\" from file \"%s\"\n", varName, ini->fileName); + *exist = 0; } } else { if (strlen(section) > 0) { - ModelicaFormatError("Cannot read section \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read section \"%s\" from file \"%s\"\n", section, ini->fileName); } else { - ModelicaFormatError("Cannot read empty section from file \"%s\"\n", + ModelicaFormatMessage("Cannot read empty section from file \"%s\"\n", ini->fileName); } + *exist = 0; } } return ret; } -const char* ED_getStringFromINI(void* _ini, const char* varName, const char* section) +const char* ED_getStringFromINI(void* _ini, const char* varName, const char* section, int* exist) { INIFile* ini = (INIFile*)_ini; + *exist = 1; if (ini != NULL) { INISection* _section = findSection(ini, section); if (_section != NULL) { INIPair* pair = findKey(_section, varName); if (pair != NULL) { - char* ret = ModelicaAllocateString(strlen(pair->value)); - strcpy(ret, pair->value); - return (const char*)ret; + if (NULL != pair->value) { + char* ret = ModelicaAllocateString(strlen(pair->value)); + strcpy(ret, pair->value); + return (const char*)ret; + } + else { + ModelicaFormatError("Cannot read value for key \"%s\" from file \"%s\"\n", + varName, ini->fileName); + *exist = 0; + } } else { - ModelicaFormatError("Cannot read key \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read key \"%s\" from file \"%s\"\n", varName, ini->fileName); + *exist = 0; } } else { if (strlen(section) > 0) { - ModelicaFormatError("Cannot read section \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read section \"%s\" from file \"%s\"\n", section, ini->fileName); } else { - ModelicaFormatError("Cannot read empty section from file \"%s\"\n", + ModelicaFormatMessage("Cannot read empty section from file \"%s\"\n", ini->fileName); } + *exist = 0; } } return ""; } -int ED_getIntFromINI(void* _ini, const char* varName, const char* section) +int ED_getIntFromINI(void* _ini, const char* varName, const char* section, int* exist) { long ret = 0; INIFile* ini = (INIFile*)_ini; + *exist = 1; if (ini != NULL) { INISection* _section = findSection(ini, section); if (_section != NULL) { INIPair* pair = findKey(_section, varName); if (pair != NULL) { - if (ED_strtol(pair->value, ini->loc, &ret)) { - ModelicaFormatError("Cannot read int value \"%s\" from file \"%s\"\n", - pair->value, ini->fileName); + if (NULL != pair->value) { + if (ED_strtol(pair->value, ini->loc, &ret)) { + ModelicaFormatError("Cannot read int value \"%s\" from file \"%s\"\n", + pair->value, ini->fileName); + } + } + else { + ModelicaFormatError("Cannot read value for key \"%s\" from file \"%s\"\n", + varName, ini->fileName); + *exist = 0; } } else { - ModelicaFormatError("Cannot read key \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read key \"%s\" from file \"%s\"\n", varName, ini->fileName); + *exist = 0; } } else { if (strlen(section) > 0) { - ModelicaFormatError("Cannot read section \"%s\" from file \"%s\"\n", + ModelicaFormatMessage("Cannot read section \"%s\" from file \"%s\"\n", section, ini->fileName); } else { - ModelicaFormatError("Cannot read empty section from file \"%s\"\n", + ModelicaFormatMessage("Cannot read empty section from file \"%s\"\n", ini->fileName); } + *exist = 0; } } return (int)ret; diff --git a/ExternData/Resources/C-Sources/ED_JSONFile.c b/ExternData/Resources/C-Sources/ED_JSONFile.c index ad795d58..c22fee7d 100644 --- a/ExternData/Resources/C-Sources/ED_JSONFile.c +++ b/ExternData/Resources/C-Sources/ED_JSONFile.c @@ -116,40 +116,36 @@ static char* findValue(JsonNodeRef* root, const char* varName, const char* fileN char* token = NULL; char* buf = strdup(varName); if (buf != NULL) { - int elementError = 0; + char* key = NULL; char* nextToken = NULL; token = strtok_r(buf, ".", &nextToken); - if (token == NULL) { - elementError = 1; - } - while (token != NULL && elementError == 0) { - size_t i; - int foundToken = 0; - for (i = 0; i < JsonNode_getChildCount(*root); i++) { - JsonNodeRef child = JsonNode_findChild(*root, token, JSON_OBJ); - if (child != NULL) { - *root = child; - token = strtok_r(NULL, ".", &nextToken); - foundToken = 1; - break; - } + while (token != NULL) { + JsonNodeRef iter = JsonNode_findChild(*root, token, JSON_OBJ); + if (NULL != iter) { + *root = iter; + token = strtok_r(NULL, ".", &nextToken); } - if (foundToken == 0) { - elementError = 1; + else { + key = token; + token = strtok_r(NULL, ".", &nextToken); + break; } } - if (token == NULL) { + if (NULL != key && NULL != *root && NULL == token) { + token = JsonNode_getPairValue(*root, key); free(buf); - ModelicaFormatError("Cannot read element \"%s\" from file \"%s\"\n", - varName, fileName); + if (NULL == token) { + ModelicaFormatMessage("Cannot read element \"%s\" from file \"%s\"\n", + varName, fileName); + *root = NULL; + } } else { - token = JsonNode_getPairValue(*root, token); free(buf); - if (token == NULL) { - ModelicaFormatError("Cannot read element \"%s\" from file \"%s\"\n", - varName, fileName); - } + ModelicaFormatMessage("Cannot read element \"%s\" from file \"%s\"\n", + varName, fileName); + *root = NULL; + token = NULL; } } else { @@ -158,10 +154,11 @@ static char* findValue(JsonNodeRef* root, const char* varName, const char* fileN return token; } -double ED_getDoubleFromJSON(void* _json, const char* varName) +double ED_getDoubleFromJSON(void* _json, const char* varName, int* exist) { double ret = 0.; JSONFile* json = (JSONFile*)_json; + *exist = 1; if (json != NULL) { JsonNodeRef root = json->root; char* token = findValue(&root, varName, json->fileName); @@ -171,17 +168,22 @@ double ED_getDoubleFromJSON(void* _json, const char* varName) token, json->fileName); } } - else { - ModelicaFormatError("Cannot read double value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Cannot read double value from file \"%s\"\n", json->fileName); + *exist = 0; + } + else { + *exist = 0; } } return ret; } -const char* ED_getStringFromJSON(void* _json, const char* varName) +const char* ED_getStringFromJSON(void* _json, const char* varName, int* exist) { JSONFile* json = (JSONFile*)_json; + *exist = 1; if (json != NULL) { JsonNodeRef root = json->root; char* token = findValue(&root, varName, json->fileName); @@ -190,18 +192,23 @@ const char* ED_getStringFromJSON(void* _json, const char* varName) strcpy(ret, token); return (const char*)ret; } - else { - ModelicaFormatError("Cannot read value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Cannot read value from file \"%s\"\n", json->fileName); + *exist = 0; + } + else { + *exist = 0; } } return ""; } -int ED_getIntFromJSON(void* _json, const char* varName) +int ED_getIntFromJSON(void* _json, const char* varName, int* exist) { long ret = 0; JSONFile* json = (JSONFile*)_json; + *exist = 1; if (json != NULL) { JsonNodeRef root = json->root; char* token = findValue(&root, varName, json->fileName); @@ -211,9 +218,13 @@ int ED_getIntFromJSON(void* _json, const char* varName) token, json->fileName); } } - else { - ModelicaFormatError("Cannot read int value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Cannot read int value from file \"%s\"\n", json->fileName); + *exist = 0; + } + else { + *exist = 0; } } return (int)ret; diff --git a/ExternData/Resources/C-Sources/ED_XLSFile.c b/ExternData/Resources/C-Sources/ED_XLSFile.c index c26982ae..25d6c914 100644 --- a/ExternData/Resources/C-Sources/ED_XLSFile.c +++ b/ExternData/Resources/C-Sources/ED_XLSFile.c @@ -150,7 +150,7 @@ static xlsWorkSheet* findSheet(XLSFile* xls, char** sheetName) } } if (sheet < 0) { - ModelicaFormatError("Cannot find sheet \"%s\" in file \"%s\"\n", + ModelicaFormatMessage("Cannot find sheet \"%s\" in file \"%s\"\n", *sheetName, xls->fileName); return NULL; } @@ -167,97 +167,172 @@ static xlsWorkSheet* findSheet(XLSFile* xls, char** sheetName) return pWS; } -double ED_getDoubleFromXLS(void* _xls, const char* cellAddress, const char* sheetName) +double ED_getDoubleFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist) { double ret = 0.; - ED_getDoubleArray2DFromXLS(_xls, cellAddress, sheetName, &ret, 1, 1); + XLSFile* xls = (XLSFile*)_xls; + *exist = 1; + if (xls != NULL) { + char* _sheetName = (char*)sheetName; + xlsWorkSheet* pWS = findSheet(xls, &_sheetName); + if (NULL != pWS) { + xlsCell* cell; + WORD row = 0, col = 0; + + rc(cellAddress, &row, &col); + cell = xls_cell(pWS, row, col); + if (cell != NULL && !cell->isHidden) { + /* Get the value of the cell (either numeric or string) */ + if (cell->id == XLS_RECORD_RK || cell->id == XLS_RECORD_MULRK || cell->id == XLS_RECORD_NUMBER) { + ret = cell->d; + } + else if (cell->id == XLS_RECORD_FORMULA) { + if (cell->l == 0) { /* It is a number */ + ret = cell->d; + } + else { + if (0 == strcmp((char*)cell->str, "bool")) { /* It is boolean */ + ret = (int)cell->d ? 1. : 0.; + } + else if (0 == strcmp((char*)cell->str, "error")) { /* Formula is in error */ + ModelicaFormatError("Error in formula of cell (%u,%u) in sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + } + else { /* Valid formula result */ + if (ED_strtod((char*)cell->str, xls->loc, &ret)) { + ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, cell->str, _sheetName, xls->fileName); + } + } + } + } + else if (cell->str != NULL) { + if (ED_strtod((char*)cell->str, xls->loc, &ret)) { + ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, cell->str, _sheetName, xls->fileName); + } + } + else { + *exist = 0; + } + } + else { + ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", + (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + *exist = 0; + } + } + else { + *exist = 0; + } + } return ret; } -const char* ED_getStringFromXLS(void* _xls, const char* cellAddress, const char* sheetName) +const char* ED_getStringFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist) { XLSFile* xls = (XLSFile*)_xls; + *exist = 1; if (xls != NULL) { char* _sheetName = (char*)sheetName; xlsWorkSheet* pWS = findSheet(xls, &_sheetName); - xlsCell* cell; - WORD row = 0, col = 0; + if (NULL != pWS) { + xlsCell* cell; + WORD row = 0, col = 0; - rc(cellAddress, &row, &col); - cell = xls_cell(pWS, row, col); - if (cell != NULL && !cell->isHidden) { - /* Get the string value of the cell */ - if (cell->id == XLS_RECORD_FORMULA) { - if (cell->l != 0) { /* It is not a number */ - if ((0 != strcmp((char*)cell->str, "bool")) && /* It is not boolean and */ - (0 != strcmp((char*)cell->str, "error"))) { /* formula is not in error */ - char* ret = ModelicaAllocateString(strlen((char*)cell->str)); - strcpy(ret, (char*)cell->str); - return (const char*)ret; + rc(cellAddress, &row, &col); + cell = xls_cell(pWS, row, col); + if (cell != NULL && !cell->isHidden) { + /* Get the string value of the cell */ + if (cell->id == XLS_RECORD_FORMULA) { + if (cell->l != 0) { /* It is not a number */ + if ((0 != strcmp((char*)cell->str, "bool")) && /* It is not boolean and */ + (0 != strcmp((char*)cell->str, "error"))) { /* formula is not in error */ + char* ret = ModelicaAllocateString(strlen((char*)cell->str)); + strcpy(ret, (char*)cell->str); + return (const char*)ret; + } } } + else if (cell->str != NULL) { + char* ret = ModelicaAllocateString(strlen((char*)cell->str)); + strcpy(ret, (char*)cell->str); + return (const char*)ret; + } + else { + *exist = 0; + } } - else if (cell->str != NULL) { - char* ret = ModelicaAllocateString(strlen((char*)cell->str)); - strcpy(ret, (char*)cell->str); - return (const char*)ret; + else { + ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", + (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + *exist = 0; } } else { - ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", - (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + *exist = 0; } } return ""; } -int ED_getIntFromXLS(void* _xls, const char* cellAddress, const char* sheetName) +int ED_getIntFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist) { long ret = 0; XLSFile* xls = (XLSFile*)_xls; + *exist = 1; if (xls != NULL) { char* _sheetName = (char*)sheetName; xlsWorkSheet* pWS = findSheet(xls, &_sheetName); - xlsCell* cell; - WORD row = 0, col = 0; + if (NULL != pWS) { + xlsCell* cell; + WORD row = 0, col = 0; - rc(cellAddress, &row, &col); - cell = xls_cell(pWS, row, col); - if (cell != NULL && !cell->isHidden) { - /* Get the value of the cell (either numeric or string) */ - if (cell->id == XLS_RECORD_RK || cell->id == XLS_RECORD_MULRK || cell->id == XLS_RECORD_NUMBER) { - ret = (long)cell->d; - } - else if (cell->id == XLS_RECORD_FORMULA) { - if (cell->l == 0) { /* It is a number */ + rc(cellAddress, &row, &col); + cell = xls_cell(pWS, row, col); + if (cell != NULL && !cell->isHidden) { + /* Get the value of the cell (either numeric or string) */ + if (cell->id == XLS_RECORD_RK || cell->id == XLS_RECORD_MULRK || cell->id == XLS_RECORD_NUMBER) { ret = (long)cell->d; } - else { - if (0 == strcmp((char*)cell->str, "bool")) { /* It is boolean */ - ret = (long)cell->d ? 1 : 0; - } - else if (0 == strcmp((char*)cell->str, "error")) { /* Formula is in error */ - ModelicaFormatError("Error in formula of cell (%u,%u) in sheet \"%s\" of file \"%s\"\n", - (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + else if (cell->id == XLS_RECORD_FORMULA) { + if (cell->l == 0) { /* It is a number */ + ret = (long)cell->d; } - else { /* Valid formula result */ - if (ED_strtol((char*)cell->str, xls->loc, &ret)) { - ModelicaFormatError("Error in cell (%u,%u) when reading int value \"%s\" from sheet \"%s\" of file \"%s\"\n", - (unsigned int)row, (unsigned int)col, (char*)cell->str, _sheetName, xls->fileName); + else { + if (0 == strcmp((char*)cell->str, "bool")) { /* It is boolean */ + ret = (long)cell->d ? 1 : 0; + } + else if (0 == strcmp((char*)cell->str, "error")) { /* Formula is in error */ + ModelicaFormatError("Error in formula of cell (%u,%u) in sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + } + else { /* Valid formula result */ + if (ED_strtol((char*)cell->str, xls->loc, &ret)) { + ModelicaFormatError("Error in cell (%u,%u) when reading int value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, (char*)cell->str, _sheetName, xls->fileName); + } } } } - } - else if (cell->str != NULL) { - if (ED_strtol((char*)cell->str, xls->loc, &ret)) { - ModelicaFormatError("Error in cell (%u,%u) when reading int value \"%s\" from sheet \"%s\" of file \"%s\"\n", - (unsigned int)row, (unsigned int)col, (char*)cell->str, _sheetName, xls->fileName); + else if (cell->str != NULL) { + if (ED_strtol((char*)cell->str, xls->loc, &ret)) { + ModelicaFormatError("Error in cell (%u,%u) when reading int value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)row, (unsigned int)col, (char*)cell->str, _sheetName, xls->fileName); + } } + else { + *exist = 0; + } + } + else { + ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", + (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + *exist = 0; } } else { - ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", - (unsigned int)row, (unsigned int)col, _sheetName, xls->fileName); + *exist = 0; } } return (int)ret; @@ -269,49 +344,51 @@ void ED_getDoubleArray2DFromXLS(void* _xls, const char* cellAddress, const char* if (xls != NULL) { char* _sheetName = (char*)sheetName; xlsWorkSheet* pWS = findSheet(xls, &_sheetName); - WORD row = 0, col = 0; - WORD i, j; + if (NULL != pWS) { + WORD row = 0, col = 0; + WORD i, j; - rc(cellAddress, &row, &col); - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) { - xlsCell* cell = xls_cell(pWS, row + i, col + j); - if (cell != NULL && !cell->isHidden) { - /* Get the value of the cell (either numeric or string) */ - if (cell->id == XLS_RECORD_RK || cell->id == XLS_RECORD_MULRK || cell->id == XLS_RECORD_NUMBER) { - a[i*n + j] = cell->d; - } - else if (cell->id == XLS_RECORD_FORMULA) { - if (cell->l == 0) { /* It is a number */ + rc(cellAddress, &row, &col); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) { + xlsCell* cell = xls_cell(pWS, row + i, col + j); + if (cell != NULL && !cell->isHidden) { + /* Get the value of the cell (either numeric or string) */ + if (cell->id == XLS_RECORD_RK || cell->id == XLS_RECORD_MULRK || cell->id == XLS_RECORD_NUMBER) { a[i*n + j] = cell->d; } - else { - if (0 == strcmp((char*)cell->str, "bool")) { /* It is boolean */ - a[i*n + j] = (int)cell->d ? 1. : 0.; + else if (cell->id == XLS_RECORD_FORMULA) { + if (cell->l == 0) { /* It is a number */ + a[i*n + j] = cell->d; } - else if (0 == strcmp((char*)cell->str, "error")) { /* Formula is in error */ - ModelicaFormatError("Error in formula of cell (%u,%u) in sheet \"%s\" of file \"%s\"\n", - (unsigned int)(row + i), (unsigned int)(col + j), _sheetName, xls->fileName); - } - else { /* Valid formula result */ - if (ED_strtod((char*)cell->str, xls->loc, &a[i*n + j])) { - ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", - (unsigned int)(row + i), (unsigned int)(col + j), cell->str, _sheetName, xls->fileName); + else { + if (0 == strcmp((char*)cell->str, "bool")) { /* It is boolean */ + a[i*n + j] = (int)cell->d ? 1. : 0.; + } + else if (0 == strcmp((char*)cell->str, "error")) { /* Formula is in error */ + ModelicaFormatError("Error in formula of cell (%u,%u) in sheet \"%s\" of file \"%s\"\n", + (unsigned int)(row + i), (unsigned int)(col + j), _sheetName, xls->fileName); + } + else { /* Valid formula result */ + if (ED_strtod((char*)cell->str, xls->loc, &a[i*n + j])) { + ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)(row + i), (unsigned int)(col + j), cell->str, _sheetName, xls->fileName); + } } } } - } - else if (cell->str != NULL) { - if (ED_strtod((char*)cell->str, xls->loc, &a[i*n + j])) { - ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", - (unsigned int)(row + i), (unsigned int)(col + j), cell->str, _sheetName, xls->fileName); + else if (cell->str != NULL) { + if (ED_strtod((char*)cell->str, xls->loc, &a[i*n + j])) { + ModelicaFormatError("Error in cell (%u,%u) when reading double value \"%s\" from sheet \"%s\" of file \"%s\"\n", + (unsigned int)(row + i), (unsigned int)(col + j), cell->str, _sheetName, xls->fileName); + } } } - } - else { - a[i*n + j] = 0.; - ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", - (unsigned int)(row + i), (unsigned int)(col + j), _sheetName, xls->fileName); + else { + a[i*n + j] = 0.; + ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", + (unsigned int)(row + i), (unsigned int)(col + j), _sheetName, xls->fileName); + } } } } diff --git a/ExternData/Resources/C-Sources/ED_XLSXFile.c b/ExternData/Resources/C-Sources/ED_XLSXFile.c index 63a65889..e377c246 100644 --- a/ExternData/Resources/C-Sources/ED_XLSXFile.c +++ b/ExternData/Resources/C-Sources/ED_XLSXFile.c @@ -266,7 +266,7 @@ static XmlNodeRef findSheet(XLSXFile* xlsx, char** sheetName) HASH_FIND_STR(xlsx->sheets, *sheetName, iter); if (iter == NULL) { - ModelicaFormatError("Cannot find sheet name \"%s\" in file \"%s\" of file \"%s\"\n", + ModelicaFormatMessage("Cannot find sheet name \"%s\" in file \"%s\" of file \"%s\"\n", *sheetName, WB_XML, xlsx->fileName); return NULL; } @@ -369,10 +369,11 @@ static char* findCellValue(XLSXFile* xlsx, const char* cellAddress, XmlNodeRef r return token; } -double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName) +double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist) { double ret = 0.; XLSXFile* xlsx = (XLSXFile*)_xlsx; + *exist = 1; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; XmlNodeRef root = findSheet(xlsx, &_sheetName); @@ -389,15 +390,20 @@ double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sh rc(cellAddress, &row, &col); ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", (unsigned int)row, (unsigned int)col, sheetName, xlsx->fileName); + *exist = 0; } } + else { + *exist = 0; + } } return ret; } -const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName) +const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist) { XLSXFile* xlsx = (XLSXFile*)_xlsx; + *exist = 1; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; XmlNodeRef root = findSheet(xlsx, &_sheetName); @@ -413,16 +419,21 @@ const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const cha rc(cellAddress, &row, &col); ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", (unsigned int)row, (unsigned int)col, sheetName, xlsx->fileName); + *exist = 0; } } + else { + *exist = 0; + } } return ""; } -int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName) +int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist) { long ret = 0; XLSXFile* xlsx = (XLSXFile*)_xlsx; + *exist = 1; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; XmlNodeRef root = findSheet(xlsx, &_sheetName); @@ -439,8 +450,12 @@ int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetNam rc(cellAddress, &row, &col); ModelicaFormatMessage("Cannot get cell (%u,%u) in sheet \"%s\" from file \"%s\"\n", (unsigned int)row, (unsigned int)col, sheetName, xlsx->fileName); + *exist = 0; } } + else { + *exist = 0; + } } return (int)ret; } diff --git a/ExternData/Resources/C-Sources/ED_XMLFile.c b/ExternData/Resources/C-Sources/ED_XMLFile.c index 5f9f3790..921b4670 100644 --- a/ExternData/Resources/C-Sources/ED_XMLFile.c +++ b/ExternData/Resources/C-Sources/ED_XMLFile.c @@ -123,27 +123,25 @@ static char* findValue(XmlNodeRef* root, const char* varName, const char* fileNa elementError = 1; } while (token != NULL && elementError == 0) { - size_t i; - int foundToken = 0; - for (i = 0; i < XmlNode_getChildCount(*root); i++) { - XmlNodeRef child = XmlNode_getChild(*root, i); - if (XmlNode_isTag(child, token)) { - *root = child; - token = strtok_r(NULL, ".", &nextToken); - foundToken = 1; - break; - } + XmlNodeRef iter = XmlNode_findChild(*root, token); + if (NULL != iter) { + *root = iter; + token = strtok_r(NULL, ".", &nextToken); } - if (foundToken == 0) { + else { elementError = 1; } } free(buf); - if (elementError == 1) { - ModelicaFormatError("Error in line %i: Cannot find element \"%s\" in file \"%s\"\n", + if (0 == elementError) { + XmlNode_getValue(*root, &token); + } + else { + ModelicaFormatMessage("Error in line %i: Cannot find element \"%s\" in file \"%s\"\n", XmlNode_getLine(*root), varName, fileName); + *root = NULL; + token = NULL; } - XmlNode_getValue(*root, &token); } else { ModelicaError("Memory allocation error\n"); @@ -151,10 +149,11 @@ static char* findValue(XmlNodeRef* root, const char* varName, const char* fileNa return token; } -double ED_getDoubleFromXML(void* _xml, const char* varName) +double ED_getDoubleFromXML(void* _xml, const char* varName, int* exist) { double ret = 0.; XMLFile* xml = (XMLFile*)_xml; + *exist = 1; if (xml != NULL) { XmlNodeRef root = xml->root; char* token = findValue(&root, varName, xml->fileName); @@ -164,17 +163,22 @@ double ED_getDoubleFromXML(void* _xml, const char* varName) XmlNode_getLine(root), token, xml->fileName); } } - else { - ModelicaFormatError("Error in line %i: Cannot read double value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Error in line %i: Cannot read double value from file \"%s\"\n", XmlNode_getLine(root), xml->fileName); + *exist = 0; + } + else { + *exist = 0; } } return ret; } -const char* ED_getStringFromXML(void* _xml, const char* varName) +const char* ED_getStringFromXML(void* _xml, const char* varName, int* exist) { XMLFile* xml = (XMLFile*)_xml; + *exist = 1; if (xml != NULL) { XmlNodeRef root = xml->root; char* token = findValue(&root, varName, xml->fileName); @@ -183,18 +187,23 @@ const char* ED_getStringFromXML(void* _xml, const char* varName) strcpy(ret, token); return (const char*)ret; } - else { - ModelicaFormatError("Error in line %i: Cannot read value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Error in line %i: Cannot read value from file \"%s\"\n", XmlNode_getLine(root), xml->fileName); + *exist = 0; + } + else { + *exist = 0; } } return ""; } -int ED_getIntFromXML(void* _xml, const char* varName) +int ED_getIntFromXML(void* _xml, const char* varName, int* exist) { long ret = 0; XMLFile* xml = (XMLFile*)_xml; + *exist = 1; if (xml != NULL) { XmlNodeRef root = xml->root; char* token = findValue(&root, varName, xml->fileName); @@ -204,9 +213,13 @@ int ED_getIntFromXML(void* _xml, const char* varName) XmlNode_getLine(root), token, xml->fileName); } } - else { - ModelicaFormatError("Error in line %i: Cannot read int value from file \"%s\"\n", + else if (NULL != root) { + ModelicaFormatMessage("Error in line %i: Cannot read int value from file \"%s\"\n", XmlNode_getLine(root), xml->fileName); + *exist = 0; + } + else { + *exist = 0; } } return (int)ret; diff --git a/ExternData/Resources/Include/ED_INIFile.h b/ExternData/Resources/Include/ED_INIFile.h index d07aba60..f8d1746c 100644 --- a/ExternData/Resources/Include/ED_INIFile.h +++ b/ExternData/Resources/Include/ED_INIFile.h @@ -31,8 +31,8 @@ void* ED_createINI(const char* fileName, int verbose); void ED_destroyINI(void* _ini); -double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section); -const char* ED_getStringFromINI(void* _ini, const char* varName, const char* section); -int ED_getIntFromINI(void* _ini, const char* varName, const char* section); +double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section, int* exist); +const char* ED_getStringFromINI(void* _ini, const char* varName, const char* section, int* exist); +int ED_getIntFromINI(void* _ini, const char* varName, const char* section, int* exist); #endif diff --git a/ExternData/Resources/Include/ED_JSONFile.h b/ExternData/Resources/Include/ED_JSONFile.h index bdfda180..7f4938d8 100644 --- a/ExternData/Resources/Include/ED_JSONFile.h +++ b/ExternData/Resources/Include/ED_JSONFile.h @@ -31,8 +31,8 @@ void* ED_createJSON(const char* fileName, int verbose); void ED_destroyJSON(void* _json); -double ED_getDoubleFromJSON(void* _json, const char* varName); -const char* ED_getStringFromJSON(void* _json, const char* varName); -int ED_getIntFromJSON(void* _json, const char* varName); +double ED_getDoubleFromJSON(void* _json, const char* varName, int* exist); +const char* ED_getStringFromJSON(void* _json, const char* varName, int* exist); +int ED_getIntFromJSON(void* _json, const char* varName, int* exist); #endif diff --git a/ExternData/Resources/Include/ED_XLSFile.h b/ExternData/Resources/Include/ED_XLSFile.h index e4520e3e..df5e416c 100644 --- a/ExternData/Resources/Include/ED_XLSFile.h +++ b/ExternData/Resources/Include/ED_XLSFile.h @@ -31,9 +31,9 @@ void* ED_createXLS(const char* fileName, const char* encoding, int verbose); void ED_destroyXLS(void* _xls); -double ED_getDoubleFromXLS(void* _xls, const char* cellAddress, const char* sheetName); -const char* ED_getStringFromXLS(void* _xls, const char* cellAddress, const char* sheetName); -int ED_getIntFromXLS(void* _xls, const char* cellAddress, const char* sheetName); +double ED_getDoubleFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist); +const char* ED_getStringFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist); +int ED_getIntFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist); void ED_getDoubleArray2DFromXLS(void* _xls, const char* cellAddress, const char* sheetName, double* a, size_t m, size_t n); #endif diff --git a/ExternData/Resources/Include/ED_XLSXFile.h b/ExternData/Resources/Include/ED_XLSXFile.h index 2c262e08..46aa9ae3 100644 --- a/ExternData/Resources/Include/ED_XLSXFile.h +++ b/ExternData/Resources/Include/ED_XLSXFile.h @@ -31,9 +31,9 @@ void* ED_createXLSX(const char* fileName, int verbose); void ED_destroyXLSX(void* _xlsx); -double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName); -const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName); -int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName); +double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist); +const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist); +int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist); void ED_getDoubleArray2DFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, double* a, size_t m, size_t n); #endif diff --git a/ExternData/Resources/Include/ED_XMLFile.h b/ExternData/Resources/Include/ED_XMLFile.h index 27689738..2232b369 100644 --- a/ExternData/Resources/Include/ED_XMLFile.h +++ b/ExternData/Resources/Include/ED_XMLFile.h @@ -32,9 +32,9 @@ void* ED_createXML(const char* fileName, int verbose); void ED_destroyXML(void* _xml); -double ED_getDoubleFromXML(void* _xml, const char* varName); -const char* ED_getStringFromXML(void* _xml, const char* varName); -int ED_getIntFromXML(void* _xml, const char* varName); +double ED_getDoubleFromXML(void* _xml, const char* varName, int* exist); +const char* ED_getStringFromXML(void* _xml, const char* varName, int* exist); +int ED_getIntFromXML(void* _xml, const char* varName, int* exist); void ED_getDoubleArray1DFromXML(void* _xml, const char* varName, double* a, size_t n); void ED_getDoubleArray2DFromXML(void* _xml, const char* varName, double* a, size_t m, size_t n); diff --git a/ExternData/package.mo b/ExternData/package.mo index e66f7621..8679d4b7 100644 --- a/ExternData/package.mo +++ b/ExternData/package.mo @@ -270,7 +270,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL extends Interfaces.partialGetReal; input String section="" "Section"; input Types.ExternINIFile ini "External INI file object"; - external "C" y=ED_getDoubleFromINI(ini, varName, section) annotation( + external "C" y=ED_getDoubleFromINI(ini, varName, section, exist) annotation( __iti_dll = "ITI_ED_INIFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_INIFile.h\"", @@ -281,7 +281,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL extends Interfaces.partialGetInteger; input String section="" "Section"; input Types.ExternINIFile ini "External INI file object"; - external "C" y=ED_getIntFromINI(ini, varName, section) annotation( + external "C" y=ED_getIntFromINI(ini, varName, section, exist) annotation( __iti_dll = "ITI_ED_INIFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_INIFile.h\"", @@ -292,8 +292,11 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL extends Interfaces.partialGetBoolean; input String section="" "Section"; input Types.ExternINIFile ini "External INI file object"; + protected + Real aux; algorithm - y := getReal(ini=ini, varName=varName, section=section) <> 0; + (aux, exist) := getReal(ini=ini, varName=varName, section=section); + y := aux <> 0; annotation(Inline=true); end getBoolean; @@ -301,7 +304,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL extends Interfaces.partialGetString; input String section="" "Section"; input Types.ExternINIFile ini "External INI file object"; - external "C" str=ED_getStringFromINI(ini, varName, section) annotation( + external "C" str=ED_getStringFromINI(ini, varName, section, exist) annotation( __iti_dll = "ITI_ED_INIFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_INIFile.h\"", @@ -315,7 +318,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getReal "Get scalar Real value from JSON file" extends Interfaces.partialGetReal; input Types.ExternJSONFile json "External JSON file object"; - external "C" y=ED_getDoubleFromJSON(json, varName) annotation( + external "C" y=ED_getDoubleFromJSON(json, varName, exist) annotation( __iti_dll = "ITI_ED_JSONFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_JSONFile.h\"", @@ -325,7 +328,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getInteger "Get scalar Integer value from JSON file" extends Interfaces.partialGetInteger; input Types.ExternJSONFile json "External JSON file object"; - external "C" y=ED_getIntFromJSON(json, varName) annotation( + external "C" y=ED_getIntFromJSON(json, varName, exist) annotation( __iti_dll = "ITI_ED_JSONFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_JSONFile.h\"", @@ -343,7 +346,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getString "Get scalar String value from JSON file" extends Interfaces.partialGetString; input Types.ExternJSONFile json "External JSON file object"; - external "C" str=ED_getStringFromJSON(json, varName) annotation( + external "C" str=ED_getStringFromJSON(json, varName, exist) annotation( __iti_dll = "ITI_ED_JSONFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_JSONFile.h\"", @@ -391,7 +394,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSFile xls "External Excel XLS file object"; output Real y "Real value"; - external "C" y=ED_getDoubleFromXLS(xls, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to 0.0"; + external "C" y=ED_getDoubleFromXLS(xls, cellAddress, sheetName, exist) annotation( __iti_dll = "ITI_ED_XLSFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSFile.h\"", @@ -419,7 +423,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSFile xls "External Excel XLS file object"; output Integer y "Integer value"; - external "C" y=ED_getIntFromXLS(xls, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to 0"; + external "C" y=ED_getIntFromXLS(xls, cellAddress, sheetName, exist) annotation( __iti_dll = "ITI_ED_XLSFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSFile.h\"", @@ -432,8 +437,12 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSFile xls "External Excel XLS file object"; output Boolean y "Boolean value"; + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to false"; + protected + Real aux; algorithm - y := getReal(xls=xls, cellAddress=cellAddress, sheetName=sheetName) <> 0; + (aux, exist) := getReal(xls=xls, cellAddress=cellAddress, sheetName=sheetName); + y := aux <> 0; annotation(Inline=true); end getBoolean; @@ -443,7 +452,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSFile xls "External Excel XLS file object"; output String str "String value"; - external "C" str=ED_getStringFromXLS(xls, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to an empty string"; + external "C" str=ED_getStringFromXLS(xls, cellAddress, sheetName, exist) annotation( __iti_dll = "ITI_ED_XLSFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSFile.h\"", @@ -460,7 +470,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; output Real y "Real value"; - external "C" y=ED_getDoubleFromXLSX(xlsx, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to 0.0"; + external "C" y=ED_getDoubleFromXLSX(xlsx, cellAddress, sheetName, exist) annotation( __iti_dll = "ITI_ED_XLSXFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSXFile.h\"", @@ -488,7 +499,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; output Integer y "Integer value"; - external "C" y=ED_getIntFromXLSX(xlsx, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set 0"; + external "C" y=ED_getIntFromXLSX(xlsx, cellAddress, sheetName, true) annotation( __iti_dll = "ITI_ED_XLSXFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSXFile.h\"", @@ -501,8 +513,12 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; output Boolean y "Boolean value"; + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to false"; + protected + Real aux; algorithm - y := getReal(xlsx=xlsx, cellAddress=cellAddress, sheetName=sheetName) <> 0; + (aux, exist) := getReal(xlsx=xlsx, cellAddress=cellAddress, sheetName=sheetName); + y := aux <> 0; annotation(Inline=true); end getBoolean; @@ -512,7 +528,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL input String sheetName="" "Sheet name"; input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; output String str "String value"; - external "C" str=ED_getStringFromXLSX(xlsx, cellAddress, sheetName) annotation( + output Boolean exist "= true, if cellAddress exits; = false, if it does not exist and y is set to an empty string"; + external "C" str=ED_getStringFromXLSX(xlsx, cellAddress, sheetName, exist) annotation( __iti_dll = "ITI_ED_XLSXFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XLSXFile.h\"", @@ -526,7 +543,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getReal "Get scalar Real value from XML file" extends Interfaces.partialGetReal; input Types.ExternXMLFile xml "External XML file object"; - external "C" y=ED_getDoubleFromXML(xml, varName) annotation( + external "C" y=ED_getDoubleFromXML(xml, varName, exist) annotation( __iti_dll = "ITI_ED_XMLFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XMLFile.h\"", @@ -563,7 +580,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getInteger "Get scalar Integer value from XML file" extends Interfaces.partialGetInteger; input Types.ExternXMLFile xml "External XML file object"; - external "C" y=ED_getIntFromXML(xml, varName) annotation( + external "C" y=ED_getIntFromXML(xml, varName, exist) annotation( __iti_dll = "ITI_ED_XMLFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XMLFile.h\"", @@ -573,15 +590,18 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL function getBoolean "Get scalar Boolean value from XML file" extends Interfaces.partialGetBoolean; input Types.ExternXMLFile xml "External XML file object"; + protected + Real aux; algorithm - y := getReal(xml=xml, varName=varName) <> 0; + (aux, exist) := getReal(xml=xml, varName=varName); + y := aux <> 0; annotation(Inline=true); end getBoolean; function getString "Get scalar String value from XML file" extends Interfaces.partialGetString; input Types.ExternXMLFile xml "External XML file object"; - external "C" str=ED_getStringFromXML(xml, varName) annotation( + external "C" str=ED_getStringFromXML(xml, varName, exist) annotation( __iti_dll = "ITI_ED_XMLFile.dll", __iti_dllNoExport = true, Include = "#include \"ED_XMLFile.h\"", @@ -598,24 +618,28 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, Excel XL extends Modelica.Icons.Function; input String varName "Key"; output Real y "Real value"; + output Boolean exist "= true, if varName exits; = false, if it does not exist and y is set to 0.0"; end partialGetReal; partial function partialGetInteger extends Modelica.Icons.Function; input String varName "Key"; output Integer y "Integer value"; + output Boolean exist "= true, if varName exits; = false, if it does not exist and y is set to 0"; end partialGetInteger; partial function partialGetBoolean extends Modelica.Icons.Function; input String varName "Key"; output Boolean y "Boolean value"; + output Boolean exist "= true, if varName exits; = false, if it does not exist and y is set to false"; end partialGetBoolean; partial function partialGetString extends Modelica.Icons.Function; input String varName "Key"; output String str "String value"; + output Boolean exist "= true, if varName exits; = false, if it does not exist and str is set to a an empty string"; end partialGetString; end Interfaces;