Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't access strings in VFP arrays from FLL
Message
 
To
23/07/2004 14:16:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00927428
Message ID:
00927438
Views:
18
This message has been marked as the solution to the initial question of the thread.
Right source code your function:
void FAR ByRef_array(ParamBlk FAR *parm)
{
   int start, liCount; // Starting value of Loop (index into array)
   Value val; // Create Value structure. 
   Locator Lines_of_code; // Create Locator structure. 
   char FAR * probesetstring;
   int probesetlen;
   char Message[801];

//_BreakPoint();

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

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

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

   Lines_of_code.l_sub = 1; // Must be 1 for one dimenz array
   liCount = (int)_ALen(parm->p[0].loc.l_NTI, AL_ELEMENTS);

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


   /* ---- FOR loop to get the array elements. ---- */ 
   val.ev_type='C';

   for(start=0;start != liCount ; start ++){

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

      Lines_of_code.l_sub1 = (start+1);

      /* Store the contents of the FoxPro array into a Value Structure.*/ 
      _Load(&Lines_of_code,&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
   }
}
MartinJ


>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
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform