Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How?
Message
De
23/12/2003 08:35:38
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: How?
Divers
Thread ID:
00861516
Message ID:
00861565
Vues:
23
>I must create an FLL that can receive an array as parameter & return same array stored with new values, but I don't know how. Something like this:
>
>In VFP:
>
>DECLARE myArray[20]
>FOR i = 1 TO 20
>    myArray[i] = i
>NEXT
>Test(@myArray)
>LIST MEMO LIKE myArray
>
>
>In VC++
>
>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};
>}
>
>
>I read the Help but there is only one example. This is example of _ALen function.
>
>
>TIA

Hope this sample helps :
/*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]
Endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform