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.

Newcomers DBPro Corner / What is an Arglist, found in Matrix1 Utilities?

Author
Message
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 15th Jun 2013 09:09
Could someone please post an example of how & what a DBPro argument list is and what it does? An example that's simple to understand would be much appreciated, maybe using apples, oranges & bananas.

I did search through the forums but the only examples I could find were a little complicated for me to figure out. I also had a general look at argument lists in other languages, but this only confused me more.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Jun 2013 13:25 Edited at: 15th Jun 2013 13:26
To be honest I'm not sure, but guessing by it's name it's an argument list

Supposedly this is to be used with calling functions through the function pointers that are also made available through the M1 utilities.
The reason for them would be that DBP itself has no way of using a pointer to call a function, so you'd have to do this through a DLL. The DLL then needs to know what arguments (/parameters) to send to the pointed-to function.

For example you have a function add(a, b) and a pointer to it, pfAdd.
To successfully call this function you would create an arglist containing the two integers you want mapped to a and b (or if they are floats or whatever). You would then supply the arglist when issuing the call function ptr function (note that I did not check it up; it's actual name may be different).


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 16th Jun 2013 01:04
So, an "argument" list is a list of queued functions waiting to either be sorted, culled or executed? If so, that's very interesting stuff! Have you, or anyone else, got any simple coded examples?

I've been discovering a few of the more complex Matrix1 Utilites commands recently. I was really excited whilst playing with the "Set Presync Callback" command, if it's as good as my testing show, it's going to completely change the way I code! No more cluttering up my game loop with mundane function calls!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Jun 2013 03:09
It seems I was wrong above, they are actually intended to be used to retrieve rather than set arguments for functions.
This effectively means that you can declare a function that will take a variable amount of parameters.

I wrote a quick example for you; as you can see we must be careful to let the function know how the arguments it will receive do look. Failing to follow the correct format will throw exceptions or crash your program.




"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 16th Jun 2013 11:24
Hey that's cool! I've always wondered why DBPro didn't have flexible arguments for functions, IanM saves the day again!

Also, I found CALL FUNCTION NAME works too, so no need for pointer. Oh, regarding function pointers, is it possible to assign a pointer number to a function, or are they system generated & always random?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Jun 2013 12:22
Quote: "Oh, regarding function pointers, is it possible to assign a pointer number to a function, or are they system generated & always random?"

I did not understand that, care to elaborate?
The way his get function ptr() functions work I suppose are to look through the internal function table of the executable (since they cannot possibly be called at compile time). Thus finding a function by name will have to conduct a linear search through this table, which could be a bit time consuming to do in real-time; since the address of the function, once the program is compiled, is constant it would of course be more efficient to just retrieve the pointer once and then store it for further access.


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 17th Jun 2013 04:29
Although you didn't understand my question, you've answered it spot on! Too funny, and thanks for your help.

Arglists seem to be a fairly hefty workaround for such a limitation, but no doubt someone somewhere has found them useful.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2024-04-16 23:06:30
Your offset time is: 2024-04-16 23:06:30