>DECLARE myArray[20] >FOR i = 1 TO 20 > myArray[i] = i >NEXT >Test(@myArray) >LIST MEMO LIKE myArray >>
>void Test(ParamBlk *parm) >{ > for(int i=0;i<20;i++) > { > // Here I don't know how to acess to the i-th element of array & do > // something with it > } > >// Here I must store some data in each element of array > > _RetLogical(true); >} > > >extern C { >FoxInfo myFoxInfo[] = { > {"Test",(FPFI) Test, 1, "R"}}; > >FoxTable _FoxTable = { > (FoxTable *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo}; >} >>
/*C++ code (l_subs = 0 means a scalar variable, 1 one dim. array, 2 two dim. array subs1 and subs2 define row,col dimensions) locator (by ref) and value (by value) structures. No error and type checking - assumes an array of type numeric and an integer is passed Multiplies each array element with N */ #include <pro_ext.h> void FAR Test(ParamBlk FAR *parm) { Locator loc = parm->p[0].loc; Value val; int rows = _ALen(loc.l_NTI, AL_SUBSCRIPT1), cols = _ALen(loc.l_NTI, AL_SUBSCRIPT2), multiplier = parm->p[1].val.ev_long; loc.l_subs = 2; // 2 dim array for(int row=1;row<=rows;row++) // FP arrays start at 1 for(int col=1;col<=cols;col++) { loc.l_sub1 = row; // Set array elem to work with loc.l_sub2 = col; _Load(&loc, &val); // Get array elem val.ev_real *= multiplier; // multiply by N _Store(&loc, &val); // Store array elem } _RetLogical(true); // return .T. } FoxInfo myFoxInfo[] = { {"MultiplyArrayByN", (FPFI) Test, 2, "RI"}, }; extern "C" { FoxTable _FoxTable = { (FoxTable *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo }; }
*VFP code Dimension myArray[5,3] For ix=1 To 5 For jx=1 To 3 myArray[ix,jx] = ix*jx Endfor Endfor ? 'MyArray initial values' For ix=1 To 5 ? myArray[ix,1],myArray[ix,2],myArray[ix,3] Endfor Set Library To "c:\MyPathToFLL\myTest.fll" MultiplyArrayByN(@myArray,3) Set Library To ? 'MyArray after FLL call' For ix=1 To 5 ? myArray[ix,1],myArray[ix,2],myArray[ix,3] EndforCetin