Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I store the value in newly created array in FLL?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00926539
Message ID:
00926594
Views:
19
This message has been marked as the solution to the initial question of the thread.
I'm sorry Borislav,

Example:
// Create new variable
locFiles.l_subs = 1;
locFiles.l_sub1 = (short) liFiles;
locFiles.l_sub2 = 0;

if ((lii = _NewVar(lcS, &locFiles,NV_PRIVATE)) < 0) 
   {
   // _NewVar() returns negative Visual FoxPro error number
   _Error(lii*-1);
   }

if (liErr==0)
   {
   luVal.ev_type='C';
   for (lii=0;lii<liFiles;lii++)
       {
       luVal.ev_length=strlen(laFiles[lii]);
       if ( !(luVal.ev_handle=_AllocHand(luVal.ev_length+1)))
          _Error(182);

       _HLock(luVal.ev_handle);
       _StrCpy((char FAR *) _HandToPtr(luVal.ev_handle), laFiles[lii]);
       _SetHandSize(luVal.ev_handle,luVal.ev_length);

       locFiles.l_sub1 = (short) lii+1;
       _Store(&locFiles, &luVal);
       
       _HUnLock(luVal.ev_handle);
       _FreeHand(luVal.ev_handle);
       }

   liErr=0;
   liRet=1;
   }
Full source code

see at _NewVar() in help

bad:
loc.l_subs = 5;
right:
// one dimenz array
loc.l_subs = 1;

// two dimenz array
//loc.l_subs = 2;
MartinJ

>Here is my VFP code:
>
>RELEASE aaaa
>SET LIBRARY TO MyTest.fll
>TestArray("aaaa")
>SET LIBRARY TO
>? ALEN(aaaa,0)  && Returns -> 5
>FOR asd = 1 TO 5
>    ? aaaa[asd] && Restuns->.F. I expect 4+asd
>NEXT
>
>
>Here is my code in C code:
>
>
>#define p0 (parm->p[0].val)
>
>void TestArray(ParamBlk *parm)
>{
> Locator loc;
> char FAR *varName;
> int flag;
> int retValue;
> Value val;
>  // Null terminate character string
>  if (!_SetHandSize(p0.ev_handle,p0.ev_length+1))
>   {
>      _Error(182); // "Insufficient memory"
>   }
>   _HLock(p0.ev_handle);
>   loc.l_subs = 5;
>   val.ev_type = 'N';
>   val.ev_width = 10;
>   val.ev_length = 2;
>
>   for(int i = 0; i<5;i++)
>	{
>	 loc.l_sub1=(i+1);
>	 loc.l_sub2 = 1;
>	 _Load(&loc, &val);
>	 val.ev_real = i+5;
>	 _Store(&loc, &val);
>	}
>
>   varName = (char FAR *) _HandToPtr(p0.ev_handle);
>   varName[p0.ev_length] = '\0';
>   flag = 0;
>   if ((retValue = _NewVar(varName, &loc, flag)) < 0)
>   {
>      // _NewVar() returns negative Visual FoxPro error number
>      _Error(-retValue);
>   }
>   _HUnLock(p0.ev_handle);
>}
>
>
>FoxInfo myFoxInfo[] = {
>	{"TestArray"	 ,(FPFI) TestArray, 1,"C"},
>};
>
>
>
>extern "C"
>{
>	// the FoxTable structure
>	FoxTable _FoxTable = {
>		(FoxTable  *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
>	};
>
>}
>
>
>
>What I am doing wrong?
>
>TIA
"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