Page 1 of 1

PostPosted: Wed Jan 25, 2006 6:20 pm
by dlinder
I'm feeling pretty stupid here.

My code seemed pretty simple, but didnt' work. I put some alerts in and here's what I saw:

alert("0 " + giSteps); -- displays a value of 10
recSteps.History = chkUSHistory.checked;
alert("1 " + giSteps); -- displays a value of 10
db.newrec(&giSteps,rec);
alert("2 " + giSteps); -- displays a value of 9

I've put code in to save the value and restore it after the record is written, but I don't understand why the value got decremented.

Anyone have any ideas?

(I'm using V3 if that matters)

PostPosted: Wed Jan 25, 2006 9:06 pm
by nmc
where did you get the initial value for giSteps from?

Looks like your db had 9 rec (0-8) before the newrec() call.

PostPosted: Thu Jan 26, 2006 11:28 am
by dlinder
nmc,

I wasn't sure what you meant at first, but it hit me after a bit.

If the value of the integer you pass to the newrec function is greater than the number of records in the database, the integer will be reset to the number of records. If the value you pass is equal to or less than then number of records in the database, it is left alone.

Thanks.

PostPosted: Thu Jan 26, 2006 11:49 am
by nmc
The number returned is the index of the new created record; you can also pass -1 to newrec() if you want the new record to be appended.