You can return values from ActiveX controls or Visual FoxPro dynamic-link libraries (FLL) to Visual FoxPro.
To return values from ActiveX controls to Visual FoxPro
-
Use the RETURN statement in the control and pass a single value.
The following example returns uses a RETURN statement to return the version number stored in VERSION:
| В | Copy Code |
|---|---|
#define VERSION 101
// other code here
long CPyCtrl::GetVersion()
{
// set the version number here in variable fVersion
return VERSION;
} | |
Returning Values from FLL Libraries
When you want to return values from FLL libraries, use API functions, not native C or C++ commands.
Note: |
|---|
| When return values from an ActiveX control (.ocx) file, do not use the API functions for returning values from FLL libraries. Instead, use the RETURN statement. |
To return values from an FLL library
-
Use the API functions listed in the following table.
The following API functions should be used only for FLL libraries.
| Function | Description |
|---|---|
|
Sets the function return value to a null-terminated string. |
|
|
Sets the function return value to a currency value. |
|
|
Sets the function return value to a date. The date is specified in mm/dd/yy[yy] format. |
|
|
Sets the function return value to a date and time specified in mm/dd/yy[yy] hh:mm:ss format. |
|
|
Sets the function return value to a float value. |
|
|
Sets the function return value to a numeric value. |
|
|
Sets the function return value to a logical value. Zero is considered FALSE. Any non-zero value is considered TRUE. |
|
|
Passes a complete Visual FoxPro Value structure; any Visual FoxPro data type except for memo can be returned. You must call _RetVal(В ) to return a string that contains embedded null characters or to return a .NULL. value. |
Note: |
|---|
To return the value of an object data type, use the _RetVal() function, filling in the ev_object field in the Value structure.
|
The following example, Sum, accepts a reference to a numeric field in a table and uses _RetFloat to return the sum of the values in the field:
| В | Copy Code |
|---|---|
#include <Pro_ext.h>
Sum(ParamBlk *parm)
{
// declare variables
double tot = 0, rec_cnt;
int i = 0, workarea = -1; // -1 is current workarea
Value val;
// GO TOP
_DBRewind(workarea);
// Get RECCOUNT( )
rec_cnt = _DBRecCount(workarea);
// Loop through table
for(i = 0; i < rec_cnt; i++)
{
//Place value of the field into the Value structure
_Load(&parm->p[0].loc, &val);
// add the value to the cumulative total
tot += val.ev_real;
// SKIP 1 in the workarea
_DBSkip(workarea, 1);
}
// Return the sum value to Visual FoxPro
_RetFloat(tot, 10, 4);
}
// The Sum function receives one Reference parameter
FoxInfo myFoxInfo[] = {
{"SUM", Sum, 1,"R"}
};
FoxTable _FoxTable = {
(FoxTable *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
}; | |
Assuming there's a numeric field named amount in the currently open table, the following line of code in a Visual FoxPro program calls the function:
| В | Copy Code |
|---|---|
? SUM(@amount) | |
js editor
Web development
Note: