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

Last reviewed: June 28, 1996
Article ID: Q122591
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: kbtool kbcode kbprb
KBSubcategory: FxtoolLck


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 28, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.