PRB: How to Change Variable Value Passed by Reference in LCKLast reviewed: June 28, 1996Article 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
SYMPTOMSWhen 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.
RESOLUTIONUsually 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 }; STATUSThis behavior is by design.
|
Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a 2.50b 2.50c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |