Retrieving Strings and Byte Arrays

Retrieval of strings and byte arrays (also known as "PIblobs") is done with two arguments: a pointer to a buffer and a buffer length. When passed, the string length parameter contains the actual declared length of the buffer.

Upon return from the function call, the string length parameter contains the number of bytes of information actually copied to the buffer. For strings, this does not include the null terminator character. The function does not null terminate the string for you. This means that you must do the following:

char buff[255];

uint32 bsize = sizeof(buff);

error = piar_getarcvaluesx(ptnum, ARCflag_comp, &count, &drval, &ival, (int8 *) buff, &bsize, &istat, 0, &t, &t1, GETFIRST);

if (!error) {

 buff[bsize] = ‘\0’;

 printf("String [%s]\n", buff);

}

Remember to reset the buffer size parameter to the full length of the buffer when calling piar_getarcvaluesx in a loop, since the bsize parameter will be set to a smaller value by the function call.

Note It is possible to pass NULL for bval while passing bsize normally. This will cause piar_getarcvaluesx to return the length of the string or blob. You might then allocate a sufficiently large buffer, and then recall piar_getarcvaluesx with the function code GETSAME.

Enabling Operational Intelligence