DOCUMENT:Q122591  09-NOV-1994  [FOXMISC]
TITLE   :PRB: How to Change Variable Value Passed by Reference in LCK
PRODUCT :Microsoft Fox Miscellaneous Products
PROD/VER:2.5x 2.60 2.6a | 2.5x 2.60 2.6a | 2.5x 2.6a
OPER/SYS:WINDOWS        | MS-DOS         | MACINTOSH
KEYWORDS:kbtool kbcode kbprb

--------------------------------------------------------------------
The information in this article applies to:

 - 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.6, 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
-----------

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN
RISK. Microsoft provides this code "as is" without warranty of any kind,
either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.

             **** 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
KBCategory: kbtool kbcode kbprb
KBSubcategory:


=============================================================================

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.

Copyright Microsoft Corporation 1994.