loading
 
API ... using it to get Center of Gravity_X value
Robert Page  [3 posts]
5 years
Hi --
     I'm trying to get the COG_X value, which I think should be an integer.  I'm sorry, but I can't figure out what you're doing with all these pointers to characters.
    This is my attempt to get the COG_X value

    // get the cogx variable
    char *result;
    char *resultBuffer[16];
    memset(resultBuffer, 0 ,sizeof(resultBuffer));
    result = resultBuffer[0];
    if (rr.getVariable("COG_X", result, 1)!=1)
    {
        printf("Error in GetVariable, did not return a result");
        getchar();
        exit(-1);
    }
    else
    {
        if (stricmp(result, "COG_X")!=0)
        {
            printf("Error in GetVariable");
            getchar();
            exit(-1);
        }
    }

     It compiles, but gets a Windows error when it runs.

     Please give me some guidance.
     Thanks.
-- Robert
Anonymous 5 years
Robert,

Try


// get the cogx variable
char result[32];
if (!rr.getVariable("COG_X", result, 64))
{
    printf("Error in GetVariable, did not return a result");
    getchar();
    exit(-1);
}
else
{
    int cogx = atoi(result);
    printf("COG_X is %d", cogx);
}

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index