Very strange indeed... sqlite and the xReader are both compiled with Devc++...
Only thing I can think of is that you may need the mingwm dll. But that the sqlite one works, and the Xreader not; makes little sense. Here's the mingwm10.dll that comes with Devc++ 4.9.9.2
You probably have DevC++ on your machine, and the ming dll versions could conflict (just a passing thought, not necessarily the problem).. Place this dll in the script directory together with the Xreader3.dll, pehaps this solves the problem, which now really has me confused.
Here's the source for both dll's and they are not that different in design, the sqlite one just has some extra database stuff in it.
RadSqLite.c
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>
__declspec(dllexport) void doSql(float *param);
__declspec(dllexport) void setDatabase(float *param);
__declspec(dllexport) void getRecord(float *param);
__declspec(dllexport) void getRecordcount(float *param);
__declspec(dllexport) void debugOn(float *param);
__declspec(dllexport) void debugOff(float *param);
__declspec(dllexport) void setRecord(float *param);
void float2str();
sqlite3 *db;
char *zErrMsg = 0;
char sql[1024]="";
int db_open=0;
char dbStr[1024][1024];
int dbC = 0;
char ss[1024];
float ff[1024];
char dbname[100];
char dbgstr[100];
int dbg = 0;
//--------------------------------------------------
void debug()
{
FILE *fp;
if(!dbg) return;
fp = fopen("RadSqLite.debug","a");
if(!fp)
fp = (FILE*)open("RadSqLite.debug","w");
fprintf(fp,"%s\n",dbgstr);
fclose(fp);
}
//--------------------------------------------------
void cleanup()
{
int i;
char c;
for(i=0;i<strlen(ss);i++){
if(ss[i] == '!')
ss[i]=' ';
}
}
//--------------------------------------------------
void setRecord(float *param)
{
int i;
float f;
f = param[0];
if(f<0) f = 0; //clip the
if(f>1023) f = 1023; //limts
for(i=0;i<1024;i++){
ff[i]=param[i+1];
if(param[i+1]=0)
break;
}
float2str();
cleanup();
dbStr[(int)f][0] = 0;
strcpy(dbStr[(int)f],ss);
sprintf(dbgstr,"setRecord: %d = %s",(int)f,ss);
debug();
}
//--------------------------------------------------
static int dbCallback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
char dta[1024]="";
for(i=0; i<argc; i++){
if((strlen(argv[i])+strlen(dbStr[dbC])+1) < 1023){
strcat(dta,(argv[i] ? argv[i] : "NULL"));
//strcat(dta,argv[i]);
strcat(dta,";");
}
}
strcpy(dbStr[dbC],dta);
dbC++;
if(dbC > 1023) dbC=1023;
return 0;
}
//--------------------------------------------------
int dbOpen(char* dbName)
{
int rc=0;
int dbrc;
strcpy(dbgstr, "dbOpen: ");
strcat(dbgstr,dbName);
strcat(dbgstr,"\n");
debug();
db_open=0;
dbrc = sqlite3_open(dbName, &db);
if(dbrc){
db_open=0;
dbg=1;
sprintf(dbgstr, "Can't open database: %s\n", sqlite3_errmsg(db));
debug();
sqlite3_close(db);
rc=0;
}else{
db_open=1;
rc=1;
}
return rc;
}
//--------------------------------------------------
int dbExec(char *sql)
{
int rc=0;
int dbrc;
strcpy(dbgstr, "dbExec: ");
strcat(dbgstr,sql);
debug();
dbC = 0;
if(!db_open) return;
dbrc = sqlite3_exec(db, sql, dbCallback, 0, &zErrMsg);
if (dbrc!=SQLITE_OK ){
dbg = 1;
sprintf(dbgstr, "SQL error: %s\n", zErrMsg);
debug();
rc=0;
}else{
rc=1;
}
strcpy(dbgstr,sql);
debug();
sprintf(dbgstr,"Records returned: %d",dbC);
debug();
return rc;
}
//--------------------------------------------------
void dbClose()
{
strcpy(dbgstr, "dbClose");
debug();
if(db_open) sqlite3_close(db);
}
//--------------------------------------------------
int dbSql(char *database,char *sql)
{
int rc=0;
char statement[1024]="";
strcpy(dbgstr,sql);
debug();
sprintf(statement,sql);
if(!dbOpen(database)) return(0);
if(!dbExec(sql)) return(0);
dbClose();
return (1);
}
//----------------------------------------
void str2float()
{
int i,L,c;
L = strlen(ss);
for(i=0;i<L;i++){
c = ss[i];
ff[i] = (float)c;
}
ff[L]=0;
}
//----------------------------------------
void float2str()
{
int i;
char c[2];
ss[0]=0;
for(i=0;i<1024;i++){
c[0] = ff[i];
c[1] = 0;
if(c[0]){
strcat(ss,c);
}else{
break;
}
}
}
//----------------------------------------
void getRecordcount(float *param)
{
float f = (float)dbC;
param[0] = f;
sprintf(dbgstr,"getRecordCount: %d",dbC);
debug();
}
//----------------------------------------
void getRecord(float *param)
{
float f;
int n,i;
f = param[0];
n = (int)f;
strcpy(ss,dbStr[n]);
str2float();
for(i=0;i<1024;i++){
param[i] = ff[i];
if(ff[i]==0)
break;
}
}
//----------------------------------------
void setDatabase(float *param)
{
int i;
for(i=0;i<1024;i++){
ff[i]=param[i];
if(param[i]=0)
break;
}
float2str();
cleanup();
strcpy(dbname,ss);
}
//----------------------------------------
void doSql(float *param)
{
int i;
if(strlen(dbname) < 1) return;
for(i=0;i<1024;i++){
ff[i]=param[i];
if(param[i]=0)
break;
}
float2str();
cleanup();
strcpy(sql,ss);
dbSql(dbname,sql);
}
//----------------------------------------
void debugOn(float *param)
{
dbg = 1;
}
//----------------------------------------
void debugOff(float *param)
{
dbg = 0;
}
xreader3.c -- LoadFile() has the X-file reader parser, if you are interested
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define READY 0
#define VERTS 1
#define DONE 2
char xfile[400];
float list[10000];
float floatfilename[400];
int c1 = -1;
__declspec(dllexport) void GetCount(float* myData);
__declspec(dllexport) void GetData(float* myData);
__declspec(dllexport) void SetName(float* myData);
__declspec(dllexport) void LoadXFile(float *myData);
void LoadFile(char* filename);
void ParseVerts(char* data);
void NameToFloat(char *name);
void floatToName(float* fname);
int checkList(char *s1, char *s2, char *s3);
//----------------------------------------
void debug(char *s)
{
FILE *fp;
fp = fopen("c:\\temp\\dump.txt","a");
if(!fp)
fp = fopen("c:\\temp\\dump.txt","w");
fprintf(fp,"%s\n",s);
fclose(fp);
}
//----------------------------------------
void NameToFloat(char *name)
{
int i;
char c;
for(i=0;i<200;i++){ //clear list
floatfilename[i] = 0;
}
for(i=0; i<strlen(name);i++){
c = name[i];
floatfilename[i] = c;
}
}
//----------------------------------------
void floatToName(float* fname)
{
int i;
char c;
for(i=0;i<200;i++){
xfile[i]=0;
}
for(i=0;i<200;i++){
c = fname[i];
if(c == '/') c = '\\';
xfile[i]=c;
}
}
//----------------------------------------
void ParseVerts(char* data)
{
char s[100];
char s1[30];
char s2[30];
char s3[30];
char *p, *q;
strcpy(s,data);
q = s;
p = strstr(q,";");
if(p) *p = 0; //null terminate on ;
strcpy(s1,q);
q = p+1;
p = strstr(q,";");
if(p) *p = 0; //null terminate on ;
strcpy(s2,q);
q = p+1;
p = strstr(q,";");
if(p) *p = 0; //null terminate on ;
strcpy(s3,q);
if(!checkList(s1,s2,s3)){
list[++c1] = atof(s1);
list[++c1] = atof(s2);
list[++c1] = atof(s3);
}
}
//----------------------------------------
int checkList(char *s1, char *s2, char *s3)
{
int res = 0;
float f1,f2,f3;
int i;
f1 = atof(s1);
f2 = atof(s2);
f3 = atof(s3);
for(i=0;i<c1; i+=3){
if(f1==list[i] && f2==list[i+1] && f3==list[i+2]){
res = 1;
break;
}
}
return res;
}
//----------------------------------------
void LoadFile(char* filename)
{
FILE *fp;
char fdata[200];
int lines = 0;
int state = READY;
c1 = -1; //<--- Bug fix: Added this to reset counter on each new load
fp = fopen(filename,"r");
if(fp){
while(!feof(fp)){
lines++;
if(lines > 3333) break;
fgets(fdata,200,fp);
if(strstr(fdata,"Mesh "))
state = VERTS;
if(state == VERTS){
if(strstr(fdata,";;"))
state = DONE;
if(strstr(fdata,";,"))
ParseVerts(fdata);
if(strstr(fdata,";;"))
ParseVerts(fdata);
if(state == DONE) //all done
break;
}
if(feof(fp)) break;
}
fclose(fp);
}
}
//----------------------------------------
void GetCount(float* myData)
{
char txt[10];
myData[0] = c1;
}
//----------------------------------------
void GetData(float* myData)
{
int i;
for(i=0;i<c1;i++)
myData[i] = list[i];
}
//----------------------------------------
void SetName(float* myData)
{
int i;
float n;
for(i=0;i<200;i++)
floatfilename[i] = 0;
for(i=0;i<200;i++){
n = myData[i];
if(n>0)
floatfilename[i] = n;
else
break;
}
floatToName(floatfilename);
}
//----------------------------------------
void LoadXFile(float *myData)
{
int i;
for(i=0;i<10000;i++)
list[i] = 0;
LoadFile(xfile);
}
Let's hope the problem was the lack of mingwm10.dll but that sqlite works makes this an interesting mystery.
Edit: After some thought, mingwm10.dll should not really make a difference, because the dll uses nothing specific to *Win* except the external declarations and the format of the DLL-load-header of the file.. Also nothing that requires Ming->Win translation, since there the code is pure ANSI-C.. Only windows.h is required for the dll, but there is no external links except for sqlite.lib in the sqlite dll (perhaps it has some win specific code in its Lib... no idea).... But surprise me and tell me mingwm10.dll makes a difference
Edit2: Aha I found a small bug.(though this did not effect 1st time load). fixed and uploaded latest xreader3.dll (See source above for details)
Edit3: uploaded the compiled project.. Maybe this may not run on your machine.. It runs perfectly on mine.. Should narrow down the problem