2018-08-17 12:27 AM - last edited on 2022-11-30 10:50 AM by Daniel Kassai
/* Example II -- loop through all attributes of a kind */ API_Attribute attrib; short nLin, i; GSErrCode err; BNZeroMemory(&attrib, sizeof(API_Attribute)); attrib.header.typeID = API_CompWallID; err = ACAPI_Attribute_GetNum(API_CompWallID, &nLin); for (i = 1; i <= nLin && err == NoError; i++) { attrib.header.index = i; err = ACAPI_Attribute_Get(&attrib); if (err == NoError) { char TTT[100] = "TEST"; int TTT_Idx; char AttTxt = *attrib.compWall.head.name; if (AttTxt == *TTT) { DGAlert(DG_INFORMATION, "ERR1", "ATTRIB GUT", "", "Good"); TTT_Idx = attrib.compWall.head.index; }Example 1 didn't work at all. I tried building header but search ends up with an error.
//Example I API_Attribute attrib; BNZeroMemory(&attrib, sizeof(API_Attribute)); char TTT[256] = "TEST"; attrib.header.name[256] = *TTT; err = ACAPI_Attribute_Search(&attrib.header); if (err == NoError) { char msgStr[512]; sprintf(msgStr, "[%d] %s", attrib.header.index, attrib.header.name); ACAPI_WriteReport(msgStr, true); DGAlert(DG_INFORMATION, "ERR1", msgStr, "", "Good"); } else { DGAlert(DG_INFORMATION, "ERR1", "error", "", "Good"); }Please help
Solved! Go to Solution.
2018-08-17 10:58 AM
kzaremba wrote:This way you copied only the first character of the attrib.compWall.head.name string to the AttTxt variable and in the if statement you compared only the first character of TTT to AttTxt.
/* Example II -- loop through all attributes of a kind */ ... char AttTxt = *attrib.compWall.head.name; if (AttTxt == *TTT) { ...
/* Example II -- loop through all attributes of a kind */ ... if (strcmp (attrib.compWall.head.name, TTT) == 0) { ...You don't need the AttTxt variable and you can compare (char*) strings using strcmp method.
kzaremba wrote:This way only the first character from TTT will be copied.
//Example I ... char TTT[256] = "TEST"; attrib.header.name[256] = *TTT; ...
//Example I ... strcpy (attrib.header.name, "TEST"); ...
2018-08-17 10:58 AM
kzaremba wrote:This way you copied only the first character of the attrib.compWall.head.name string to the AttTxt variable and in the if statement you compared only the first character of TTT to AttTxt.
/* Example II -- loop through all attributes of a kind */ ... char AttTxt = *attrib.compWall.head.name; if (AttTxt == *TTT) { ...
/* Example II -- loop through all attributes of a kind */ ... if (strcmp (attrib.compWall.head.name, TTT) == 0) { ...You don't need the AttTxt variable and you can compare (char*) strings using strcmp method.
kzaremba wrote:This way only the first character from TTT will be copied.
//Example I ... char TTT[256] = "TEST"; attrib.header.name[256] = *TTT; ...
//Example I ... strcpy (attrib.header.name, "TEST"); ...
2018-08-20 05:29 PM
2018-08-21 02:53 PM
2018-08-22 03:24 PM
2018-08-22 04:01 PM
GS::UniString myStr = "Hello, world!"; // ... FunctionTakingCStr (myStr.ToCStr ().Get ());
2018-08-24 02:29 PM