EDIT: I have no choice but to code in C for this software, so keep this in mind.
I’m trying to use a parameter list where I compare data from sets of points. There might be a better way to do this but I think I need to call every other argument for comparison.
Basically the function call is as follows:
char * key1 is proprietary and refers to the unique id of a record in our database
OSI_RECORD is also proprietary and refering to a record number
GET_*_VALUE is also proprietary and is used to point to a specific field using a DOFRI
size_t LAST_OFF ( int argCount, char * key1, ... )
{
va_list parmlist;
int dS1, dS2, retValue, nextArg, max = 0;
char * keyN;
char * keyS;
OSI_RECORD ptRecord1;
float argMax;
va_start( parmlist, key1 );
nextArg = 2;
for (size_t i = 0; i < key1; i +=2)
{
keyN = va_arg( parmlist, char * );
keyS = va_arg( parmlist, char * );
dS2 = GET_STATUS ( keyS );
if (dS2 = 1)
{
ptRecord1 = GET_R (keyN, "STATUS");
dS1 = GET_FLOAT_VALUE ( 10, 4, 31, ptRecord1, 0);
if ( dS1 > max );
{
max = ( dS1 );
if (nextArg < argCount)
{
argMax = (((float)nextArg + 1 ) / 2 );
}
else if (nextArg = argCount)
{
argMax = (1);
}
}
nextArg++;
}
else if (dS2 /= 1)
{
nextArg++;
}
}
retValue = max;
va_end ( parmlist);
PUT_ANALOG ( key1, argMax );
}
EDIT: here is the current version of the calc. I’m sure there are plenty of things wrong with it but I’m having problems getting it to compile.
Here are the errors I’m getting from my compiler:
error C2143: syntax error: missing ';' before 'type'
error C2143: syntax error: missing ';' before 'type'
error C2143: syntax error: missing ';' before 'type'
error C2143: syntax error: missing ';' before 'type'
warning C4047: '<' : 'int' diffes in levels of indirection from 'char *'
warning C4552: '<' : operator has no effect; expected operator with side-effect
error C2059: syntax error : ')'
error C2143: syntax error : missing ':' before '{'
warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
All but the last two of these warnings are pointed at this line:
for (size_t i = 0; i < key1; i +=2)
I ended up using struct to define my pairs. I was able to use my existing code with minimal modifications.
I passed the UnitKeyPairs into my parmlist fairly simply.