PRB: How to Change Variable Value Passed by Reference in LCK

ID: Q122591

2.50x 2.60 2.60a 3.00 3.00b | 2.50x 2.60 2.60a | 2.50b 2.50c 2.60a

WINDOWS                     | MS-DOS           | MACINTOSH
  kbprb

The information in this article applies to:

- Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b - Microsoft FoxPro Library Construction Kit included with the

   Professional Edition of:

    - Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
    - Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
    - Microsoft FoxPro for Macintosh, version 2.5b, 2.5c, 2.6a

SYMPTOMS

When passing a variable by reference to a Library Construction Kit (LCK) library and changing the value of that variable in the library routine, sometimes the variable in FoxPro in not changed correctly. This behavior occurs usually with a numeric variable.

RESOLUTION

Usually VAL.EV_LONG is used when working with numbers that are passed from FoxPro. If the numeric variable is passed by reference and the user wants to change the variable so that FoxPro sees the change, then EV.TYPE should be used. The following sample code is an example.

Sample Code

             **** CODE USED IN FOXPRO ****
   CLEAR
   SET LIBRARY TO Double.fll
   x = 1.1
   ?"Before"
   ?x
   =DOUBLE(@x)
   ?"After"
   ?x
   SET LIBRARY TO

            *** CODE USED IN C TO MAKE FLL ****
   //  Double.C   Doubles the value of a variable

   #include <pro_ext.h>

   void FAR Double(ParamBlk FAR *parm)
   {
   Value val;

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

   if (val.ev_type == 'N')
       val.ev_real = 2.0 * val.ev_real;
   else if (val.ev_type == 'I')
       val.ev_long = 2 * val.ev_long;
   else
     _Error(9);  // "Data type mismatch"

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

   FoxInfo myFoxInfo[] = {
       {"DOUBLE", (FPFI) Double, 1, "R"},
   };

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

STATUS

This behavior is by design.

Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a 2.50b 2.50c 2.60 2.60a LCK 3.00 3.00b

KBCategory:   kbprb
KBSubcategory: FxtoolLck
Keywords          : kbcode FxtoolLck 
Version           : 2.50x 2.60 2.60a 3.00 3.00b | 2.
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 22, 1998