Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Parameters in FLL code

Status
Not open for further replies.

Brak

Programmer
Jul 11, 2001
158
US
Ok, I have a question in regards to constructing FLLs.
At the end of your C coding you have the following:

FoxInfo myFoxInfo[] = {
{"Test1", (FPFI) Test1, 1, "C"},
{"Test2", (FPFI) Test2, 1, "C"},
{"Test3", (FPFI) Test3, 1, "C"},
};

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

Now lets say that much of the code for Test1, Test2, and Test3 are the same, in fact there are only a few lines at the end that are different. It would be great to just have one function which will call on the unique code based upon which function is invoked. So I would like to have the end of the coding something like such:

FoxInfo myFoxInfo[] = {
{"Test1", (FPFI) Test(1), 1, "C"},
{"Test2", (FPFI) Test(2), 1, "C"},
{"Test3", (FPFI) Test(3), 1, "C"},
};

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

The idea being that the Fox functions Test1, Test2, and Test3 will all call the C function Test passing the parameter 1, 2, or 3 repectively.

I hope my question makes sense. If so how can I do that?

Thanks in advance!

B"H
Brak
 
You could add a second parameter:
Code:
FoxInfo myFoxInfo[] = {
    {"Test", (FPFI) Test, 2, "CI"},
};
...
And call function:
Code:
? Test([asdasdasd],1)
? Test([asdasdasd],2)
? Test([asdasdasd],3)

Then in C function:
Code:
void Test (ParamBlk parm)
{
 switch parm->p[1].val
    {
     case 1:
          // do simething
          break;
     case 2:
          // do simething
          break;
     case 3:
          // do simething
          break;
    }
}
I am not sure about C syntax of switch command, but you could check it

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Thanks for responding - but it doesn't direct my question.

I don't want the user to give the 2nd parameter - I want it to be in the C code itself. Let me try asking my question another way:

Say there are three people: John, Joe, and Jack. Each one has a specific function that they use in the FLL, the one for John is called JOHN, the one for Joe is called JOE, the one for Jack is called JACK.

Now the C coding for all three functions are nearly identical - there are only 5 out of 200 lines of code which differ. So I would like to use the same C function for all three FLL functions and have the unique lines of code processed according to a 2nd parameter which is passed by the C code - not the user.

So I would want something that would look like this:

FoxInfo myFoxInfo[] = {
{"JOHN", (FPFI) Test(1), 1, "C"},
{"JOE", (FPFI) Test(2), 1, "C"},
{"JACK", (FPFI) Test(3), 1, "C"},
};

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

I don't want the user to pass the 2nd variable - I want the C code to do it based upon which FLL function is called. So if the user types:
? JOHN("ABCDEF")
then C function Test with parameter 1 is passed.
If the user types:
? JOE("ABCDEF")
then C function Test with parameter 2 is passed.

I hope this clarifies my question.
 
Nope, you can't you can do that with writing FOUR functions"
Code:
void John(ParamBlk parm}
{
 Test(1, parm->p[0].val)
}

void Joe(ParamBlk parm}
{
 Test(2, parm->p[0].val)
}

void Jack(ParamBlk parm}
{
 Test(3, parm->p[0].val)
}

void Test (int iTypeFunc, char[] myString)
{
 switch iTypeFunc
    {
     case 1:
          // do simething
          break;
     case 2:
          // do simething
          break;
     case 3:
          // do simething
          break;
    }
}

FoxInfo myFoxInfo[] = {
    {"JOHN", (FPFI) Jonn, 1, "C"},
    {"JOE",  (FPFI) Joe, 1, "C"},
    {"JACK", (FPFI) Jack, 1, "C"},
};
Again I am not sure about Test function syntax, because I write thi direclty here and C isnot my native language :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
yes, or pass on parm as is:

Code:
void John(ParamBlk *parm}
{
 Test(1, &parm)
}

void Joe(ParamBlk *parm}
{
 Test(2, &parm)
}

void Jack(ParamBlk *parm}
{
 Test(3, &parm)
}

void Test (int iTypeFunc, ParamBlk *parm)
{

 ...do something ...

 ...and finally:
 switch iTypeFunc
    {
     case 1:
          // do something
          break;
     case 2:
          // do sumthing
          break;
     case 3:
          // do sumthin
          break;
    }
}

You may want to define Test() as INTERNAL function in the FoxInfo array or even simpler don't define it there at all. Notice, that even if you want to return a value from within Test() you don't need to pass on the return value from there in the the J* functions, as you do return a value by the _RetVal() API call. Only If you want your FLL (plus VFP runtimes) usable as a normal DLL from within other languages, you may use C's return command too.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top