Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Is there a way to make a DLL function with optional parameters?

Author
Message
Mike J
Retired Moderator
18
Years of Service
User Offline
Joined: 7th Jul 2006
Location: Binghamton, NY, USA
Posted: 19th Jul 2006 13:47
Many intrinsic DBPro commands have optional parameters. Is there a way to implement a function in a TPC DLL that does the same?

Thanks to all, in advance, for your advice.

"The early bird may get the worm, but the second mouse gets the cheese."
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 19th Jul 2006 14:04
i dont think those are optional arguments, they may be overloaded functions in the dll code. not sure how dbp handles this. In the dgdk.net apex had to do

functionnameA
fucntionnameB

etc
as sep functions to simulate overloads

Science, Mathematics, and Physics do not lie - only people do.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 19th Jul 2006 14:43
You would add each of the different possible functions to the resource with the same name (but different parameters), and use a different managed name for each one.

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Dont do anything I wouldn't do. But if you do, take pictures.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 19th Jul 2006 15:28
correct, so its overloaded functions in the dll code, not optional args. I don't know about other languages but in vb.net for example, there's two distinctly differnt approaches:

Optional Args to One function:
Private Function Test(byval SomeText as String, Optional Byval SomeInt As Integer = -1)As RetType
the optional arg can be omitted in the call, but the def requires a default value

Overloads:
Private Function Test() As String
Private Function Test(ByVal i As Integer) As String
Private Function Test(ByVal d As Double) As String


intellisense will show the overloads and let you choose which one you want. Arg signatures must be unique.

If I were making a plugin for dbp I could not include either of these .net techniques in the dll code, but its ok as there are easy work arounds

Science, Mathematics, and Physics do not lie - only people do.
Mike J
Retired Moderator
18
Years of Service
User Offline
Joined: 7th Jul 2006
Location: Binghamton, NY, USA
Posted: 19th Jul 2006 16:21 Edited at: 19th Jul 2006 16:22
@Philbert McTwitch - I think that is the answer I was looking for.

To make sure I understand:

The string table in my resource file can have
DO SOMETHING( X )
and
DO SOMETHING( X, Y )

(simplified for purposes of discussion) and the DBPro compiler will figure out which one to call based on the number of arguments that the user specifies in their DBA source file.

Then obviously I can attach each of the names in the resource file to any function I want in my C++ code.

"The early bird may get the worm, but the second mouse gets the cheese."
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 19th Jul 2006 21:24
Yes, but dont forget that, in C, each function must have a different name.

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Dont do anything I wouldn't do. But if you do, take pictures.
Mike J
Retired Moderator
18
Years of Service
User Offline
Joined: 7th Jul 2006
Location: Binghamton, NY, USA
Posted: 19th Jul 2006 21:28
@Philbert McTwitch - Understood. Thanks very much for your help.

"The early bird may get the worm, but the second mouse gets the cheese."

Login to post a reply

Server time is: 2024-11-25 18:13:53
Your offset time is: 2024-11-25 18:13:53