> Whoops! Um...when I try to INSERT INTO mycursor FROM ARRAY myarray, it
> tells me that the cursor is readonly. I suppose that wouldn't happen if I
> CREATE CURSOR from the beginning, but what is the most efficient way to
> make the cursor not be readonly?
I wrote this some years ago, in FPD2.6, and it works in VFP as well:
CopyCurs.prg
*+ copy into a R/W cursor
* copies the selected alias into a read/write cursor of a same;
structure. The selected alias gets closed.
*
* Parameters
* newcurs - new cursor's alias
* _talk - .t. or .f. i.e. verbose or not
*-
Para newcurs, _talk
Local Array Stru(1)
Local _settalk, _settalkx, _sel, _dbf
if set("talk",1)="WI"
set talk off
_settalk=.t.
_settalkx=.t.
else
if set("talk")="ON"
set talk off
_settalk=.t.
else
_settalk=.f.
endif
_settalkx=.f.
endif
=Afiel(Stru)
_sel=Sele()
_dbf=Dbf()
Sele 0
Crea Curs (newcurs) From Array Stru
Rele Stru
If _talk
Set talk on
Set talk window
Endif
Appe From (_dbf)
if _settalkx
set talk window
else
set talk nowindow
endif
if _settalk
set talk on
? _tally,"record(s) copied"
endif
Use In (_sel)
As you can see, the modularity overhead (keep/restore settings) took
more than the program itself :). I planned to add third parameter to
close the original alias or not, but dropped the matter for reasons of
compatibility with myself :) - I'd keep forgetting that it's not closed
and keep behaving as if it was.