Hi,
I just cracked the problem. With a little help from the guys from:
http://cboard.cprogramming.com
I can thoroughly recommend this forum if you ever have a C/C++/C# question. Very active forum, quick and to the point replies.
Not that I don't appreciate or don't trust all your help
And this is the solution (which makes me appreciate C++ even more):
Code: Select all
bool SQL_ResultWithValues(SQL_Output *SQL_Statement, const char *Typelist, ...)
{
int cType, Column;
char *TString = 0;
int *TInt = 0;
double *TDouble = 0;
va_list argp;
va_start(argp, Typelist);
for (int i = 1; i < strlen(Typelist); i += 2)
{
Column = (int)((i-1)/2);
if (!strncmp(Typelist + i - 1, "%", 1 ) )
{
cType = (int)Typelist[i];
switch (cType)
{
case 's' : case 'S' :
TString = va_arg(argp, char*);
strcpy(TString, getResultAsString(SQL_Statement, Column) );
break;
case 'd' : case 'D' :
TInt = va_arg(argp, int*);
*TInt = getResultAsInt(SQL_Statement, Column);
break;
TDouble = va_arg(argp, double*);
*TDouble = getResultAsDouble(SQL_Statement, Column);
break;
default :
printf("Unknown Type in Typelist: %s at position %d Token=%s\n", Typelist, i, Typelist[i]);
va_end(argp);
return false;
break;
}
}
else
{ printf("Error parsing Typelist: %s at position %d\n", Typelist, i);
return false;
}
}
va_end(argp);
return true;
}
I am calling this function for example with:
Code: Select all
int ID;
double Value;
char Remark[100];
DB->SQL_ResultWithValues(&SQLOut, "%d%f%s", &ID, &Value, &Remark);
printf("%d,%f,%s\n", ID, Value, Remark );
You can propably now guess what I am working on. I'll release this stuff in a couple of weeks, after a lot more testing. I promise you that the results will be awesome.