Get_buffer_char?
vining
Posts: 4,368
Why does get_buffer_char(buffer) act differently than get_buffer_string(buffer,1). It boggles my mind that in the below code I need double quote around the get_buffer_char but not the get_buffer_string(buffer,1). I would prefer not using the double quotes at all but if I do at least reiquire them consistently for any single char return. You would think that get_buffer_char would acutally call the the system function get_buffer_string and just pass it the parameter of 1.
{
STACK_VAR INTEGER nTT_PWR ;
STACK_VAR INTEGER nTT_Cntry ;
STACK_VAR INTEGER nTT_Zone ;
STACK_VAR INTEGER nTT_ST_Mono ;
STACK_VAR INTEGER nTT_FM_AM ;
STACK_VAR INTEGER nTT_Mute ;
STACK_VAR CHAR cTT_FirmWare[3] ;
STACK_VAR CHAR cTT_FreQ[6] ;
STACK_VAR CHAR cTT_Preset[2] ;
STACK_VAR CHAR cRDS_Z_NAME[8] ;
sRcvdStatMSG.StrLenght = atoi(get_buffer_string(iString,2)) ;
if(find_string(iString,"END_STAT_MSG",1) == (sRcvdStatMSG.StrLenght + 1))
{
nTT_PWR = atoi("get_buffer_char(iString)") ;
nTT_Cntry = atoi("get_buffer_char(iString)") ;
nTT_Zone = atoi(get_buffer_string(iString,1)) ;
nTT_ST_Mono = atoi("get_buffer_char(iString)") ;
nTT_FM_AM = atoi("get_buffer_char(iString)") ;
nTT_Mute = atoi(get_buffer_string(iString,1)) ;
cTT_FirmWare = get_buffer_string(iString,3) ;
cTT_FreQ = get_buffer_string(iString,6) ;
cTT_Preset = get_buffer_string(iString,2) ;
cRDS_Z_NAME = get_buffer_string(iString,8) ;
if(find_string(iString,"END_STAT_MSG",1) == 1)
{//everything apparently OK so load structure.
sRcvdStatMSG.Power = nTT_PWR ;
sRcvdStatMSG.Cntry = nTT_Cntry ;
sRcvdStatMSG.Zone = nTT_Zone ;
sRcvdStatMSG.ST_Mono = nTT_ST_Mono ;
sRcvdStatMSG.FM_AM = nTT_FM_AM ;
sRcvdStatMSG.Mute = nTT_Mute ;
sRcvdStatMSG.FirmWare = cTT_FirmWare ;
sRcvdStatMSG.FreQ = cTT_FreQ ;
sRcvdStatMSG.Preset = cTT_Preset ;
sRcvdStatMSG.RDS_Z_Name = cRDS_Z_NAME ;
CLEAR_BUFFER iString ;
RETURN TRUE ;
}
}
CLEAR_BUFFER iString ;
RETURN FALSE ; //something is wrong, so clear_buffer and abort structure loading.
}
0
Comments
I suggest that you grit your teeth, ignore the frustration, and simply put double quotes around every string expression in your code that could conceivably be a single character in your mind or the compiler's mind. I think.
Yup, that's pretty much it. After a while, it becomes second nature.
GET_BUFFER_CHAR returns a CHAR not a CHAR[1]. So the return value does not have length and is not a char array. ATOI needs a CHAR array. By adding the quotes around GET_BUFFER_CHAR you are actually creating a CHAR array via concatenation. Now ATOI is happy.
// System Function Declerations
DEFINE_FUNCTION CHAR GET_BUFFER_CHAR(CHAR cMsg[])
DEFINE_FUNCTION INTEGER ATOI(CHAR cMsg[])