注册 登录
编程论坛 VFP论坛

FLL这么写吗?如果多个函数怎么写?

ljb8864 发布于 2023-08-30 08:45, 413 次点击
#include  <pro_ext.h>
#define nl _PutChr('\n')

long FAR CTest()
{
   long rc,rec;
   int workarea = -1;
   int flag = 0;
   int rn,recn;

   rc = _DBRewind(workarea);
   _PutStr("top");  nl;
   rc = _DBSkip(workarea, 5);
   _PutStr("skipped 5");  nl;
   
   rc = _DBAppend(workarea,flag);
   _PutStr("Appending"); nl;
   rc = _DBRewind(workarea);
   _PutStr("top");  nl;
   rn = _DBRecCount(workarea);
   _RetInt(rn, 10);
   rec = rn;
   return rn;
}

FoxInfo myFoxInfo[] = {
   {"CTEST", (FPFI) CTest,0 , ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
};



缺少文件?pro_ext.h
如果多个函数怎么写?
有没有大神指教一二

[此贴子已经被作者于2023-8-30 09:12编辑过]

4 回复
#2
sxzjbb2023-08-30 10:57
一样的,同样写多个函数,然后在FoxInfo myFoxInfo[] = {
   {"CTEST", (FPFI) CTest,0 , ""},
   {"CTEST1", (FPFI) CTest1,0 , ""},
   {"CTEST2", (FPFI) CTest2,0 , ""},
   {"CTEST3", (FPFI) CTest3,0 , ""},
};    我用过,调用函数名CTEST(),具体忘了
#3
iswith2023-08-30 11:17
像这个怎么先写个Hello
// include the library construction header file
#include <pro_ext.h>

void hello(ParamBlk  *parm) // the function definition
    {
    _PutStr("\nHello, World!\n"); //print the message
    }

// the FoxInfo structure registers the function
FoxInfo myFoxInfo[] = {
    {"HELLO",(FPFI) hello, 0, ""},
};

// the FoxTable structure
FoxTable _FoxTable = {
    (FoxTable  *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
#4
ljb88642023-08-30 12:22
以下是引用sxzjbb在2023-8-30 10:57:14的发言:

一样的,同样写多个函数,然后在FoxInfo myFoxInfo[] = {
   {"CTEST", (FPFI) CTest,0 , ""},
   {"CTEST1", (FPFI) CTest1,0 , ""},
   {"CTEST2", (FPFI) CTest2,0 , ""},
   {"CTEST3", (FPFI) CTest3,0 , ""},
};    我用过,调用函数名CTEST(),具体忘了



可以的。


#include "pro_ext.h"



void FAR NewVarEx(ParamBlk FAR *parm)
{
   char FAR *varName;
   Locator loc;
   int flag;
   int retValue;

   // Null 终止字符串
   if (!_SetHandSize(parm->p[0].val.ev_handle,
      parm->p[0].val.ev_length+1))
   {
      _Error(182); // "内存不足"
   }
   _HLock(parm->p[0].val.ev_handle);
   varName = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle);
   varName[parm->p[0].val.ev_length] = '\0';
   loc.l_subs = parm->p[1].val.ev_long;
   loc.l_sub1 = parm->p[2].val.ev_long;
   loc.l_sub2 = parm->p[3].val.ev_long;
   flag = parm->p[4].val.ev_long; //0 public 1 private
   if ((retValue = _NewVar(varName, &loc, flag)) < 0){
      // _NewVar() 返回负的 Visual FoxPro 错误号
      _Error(-retValue);    }
   _HUnLock(parm->p[0].val.ev_handle);
}



void TestAdd(ParamBlk FAR *parm)
{
int x1;
x1=parm->p[0].val.ev_long + parm->p[1].val.ev_long;
 _RetInt(x1,10);  
}




FoxInfo myFoxInfo[] = {
   {"XNEWVAR", (FPFI) NewVarEx, 5, "C,I,I,I,I"},
        {"TESTADD", (FPFI) TestAdd, 2, "I,I"}

};


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



#define NV_PUBLIC   0
#define NV_PRIVATE   1
= xNewVar('var', 0, 0, 0, NV_PUBLIC) &&变量
DISPLAY MEMORY LIKE var
= xNewVar('onedim', 1, 5, 0, NV_PUBLIC) &&一维
DISPLAY MEMORY LIKE onedim
= xNewVar('twodim', 2, 5, 6, NV_PUBLIC) &&二维

[此贴子已经被作者于2023-8-30 12:40编辑过]

#5
ljb88642023-08-30 13:34
以下是引用iswith在2023-8-30 11:17:22的发言:

像这个怎么先写个Hello
// include the library construction header file
#include <pro_ext.h>


void hello(ParamBlk  *parm) // the function definition
    {
    _PutStr("\nHello, World!\n"); //print the message
    }

// the FoxInfo structure registers the function
FoxInfo myFoxInfo[] = {
    {"HELLO",(FPFI) hello, 0, ""},
};

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





以下也是:
#include <pro_ext.h>

void FAR chars(ParamBlk FAR *parm)
{
   char message[] = "Hello, world";
   _RetChar(message);
}
FoxInfo myFoxInfo[] = {
   {"CHARS", (FPFI) chars, 0, ""}
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
1