Page 1 of 1

PostPosted: Sun Jun 27, 2004 9:26 pm
by hawkweb
I am trying to make a simple database using cruise controlls. I just want to start by writing a variable to the database and recalling it.

I searched the fourm, but couldnt find a good example. I found some that worked but when I put them in this format they didnt work.

It returns 1.6841740e09 and not the data inputed.

This is what I have for the third file of my cruise control app...:

/$ database methods (CEditor)

int data1,data2,data3,i,records;

data1=1;
records=0;

on_databx(){
}
on_savebt(){
/$ data1 = Cgetcontent(databx);
dbwrite(data1);
data1++;
}
on_readlb(){
}
on_readbt(){
records=dbnrecs();
dbrec(records-1);
data3=dbread("i");

Csetcontent(readlb, format(data3,0));
Cdraw(readlb);
dbclose();
}
messageloop(){
int e;
while(1){
e=event(1);
if(Cevent(databx,e)) on_databx();
else if(Cevent(savebt,e)) on_savebt();
else if(Cevent(readlb,e)) on_readlb();
else if(Cevent(readbt,e)) on_readbt();
}
}

PostPosted: Thu Jul 08, 2004 2:29 am
by dewey
I don't see any obvious bugs, but it looks like you might be reading from a different place than you are writing. Before you call dbwrite(), you don't specify the record to write to, meaning it will append to the current record. When you can dbread(), you first specify the last database record, which reads from the beginning of that record.