Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't access strings in VFP arrays from FLL
Message
De
23/07/2004 14:16:19
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Can't access strings in VFP arrays from FLL
Divers
Thread ID:
00927428
Message ID:
00927428
Vues:
64
I am trying to access each string in a VFP array from a FLL. The FLL sees the array, but only sees the first string! Am I doing something wrong? Here is my sample code:

VFP CODE ---------------------------
SET LIBRARY TO test
DIMENSION bb[2]
bb[1] = REPLICATE('a',25)
bb[2] = REPLICATE('b',25)
? '--- ARRAY AS SEEN BY VFP ---'
? bb[1]  && aaaaaaaaaaaaaaaaaaaaaaa
? bb[2]  && bbbbbbbbbbbbbbbbbbbbbbb
? '---- ARRAY AS SEEN BY FLL ---'
byref_array(@bb)
SET LIBRARY TO
return
C++ CODE -----------------------
//test.cpp
#include pro_ext.h    // I had to take the greater than/less than off
#include stdio.h          // these to show them here on the web.
#include string

void FAR ByRef_array(ParamBlk FAR *parm)
{
int	start;         // Starting value of Loop (index into array)
Value   val;           // Create Value structure. 
Locator loc;           // Create Locator structure. 
char FAR * probesetstring;
int probesetlen;
char Message[801];

_Load(&parm->p[0].loc, &val);

loc = parm->p[0].loc;  /* Store the contents of the FoxPro array in the Locator structure. */ 

/* Get the number of elements from the FoxPro array. */ 

loc.l_subs = (int)_ALen(parm->p[0].loc.l_NTI, AL_ELEMENTS);

sprintf( Message, "\nsubscripts %u \n", loc.l_subs);
_PutStr( Message ); //print the message


/* ---- FOR loop to get the array elements. ---- */ 
	
for(start=0;start != loc.l_subs ; start ++){

	_PutStr( "-- Top of Loop -- " );

	loc.l_sub1 = (start+1);

	/* Store the contents of the FoxPro array into a Value Structure.*/ 
	_Load(&loc,&val);   // this one doen't seem to do anything, still gets the first array member
     
	probesetstring = (char FAR *) _HandToPtr(val.ev_handle);  // get a pointer to the string
	probesetlen    = (int) val.ev_length;

	sprintf( Message, "\ntype %c  length %u  %s \n", val.ev_type, probesetlen, probesetstring );
	_PutStr( Message ); //print the message
}
}

FoxInfo myFoxInfo[]={
  {"ByRef_ARRAY",(FPFI)ByRef_array,1,"R"},
};


extern "C" {
FoxTable _FoxTable={
      (FoxTable FAR*)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo };
}

THE OUTPUT --------------------------
--- ARRAY AS SEEN BY VFP ---
aaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbb
---- ARRAY AS SEEN BY FLL ---
subscripts 2
-- Top of Loop --
type C length 25 aaaaaaaaaaaaaaaaaaaaaaaaa
-- Top of Loop --
type C length 25 aaaaaaaaaaaaaaaaaaaaaaaaa
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform