>>dear all
>>I want to make an empty cursor based on one of my free table structure.
>
>In addition to Sylvain suggestion
>
>
>AFIELDS(laFields, "MyTable")
>CREATE CURSOR MyCursor FROM ARRAY laFields
>
>
>Additional few lines my come usefull to add extra fields
>and index cursor;
>
>alter table alias() add column pick L
>alter table alias() add column rec_no N(6)
>index on myCursor.keyfield tag mykey
>
>
>Beware of long field names when applied on dbc tables.
>
>HTH
Update:
Hi Reza,
(Sorry for accidentaly drifting this thread)
Before I forget; Next to long field names there is also issue
with afields() creating full structure array of 16 columns worth of
table info which includes update triggers, captions etc.
You might not need all that for memory cursors, while update/delete.. triggers might get you even in trouble if original alias is part of RI enriched/secred VFP database (DBC).
There4, in addition to what was said before here is also solution
including workarround function.
select YourAlias
local aa(1)
=afields4(@aa)
create cursor myEmptyCursor from array aa
alter table alias() add column bb c(1)
alter table alias() add column cc c(1)
index on bb tag bb
Function below will fill up array already created / passed as parameter
with fat-free table fields structure (4 out of 16 columns) convinient for creating tmp cursors
As original Afields it also returns back number of fields
function afields4
lparameters lArray
local lArrStru(1) , i , j
declare lArray(afields(lArrStru), 4 )
for i=1 to alen(lArrStru,1)
for j = 1 to 4
lArray(i,j) = lArrStru(i,j)
next
next
return alen(lArray,1)
HTH