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.

DarkBASIC Professional Discussion / Matrix1Util Crash using "Call Function Name" and DATA statement

Author
Message
pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 3rd Jul 2013 17:40
If you have Matrix1Util dll, please test the following code.



Try calling Test() both ways. I am getting a crash using call function name.

Thanks.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jul 2013 19:06
Try this:



I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 3rd Jul 2013 19:08
I don't get a crash, but the code exits immediately. I haven't had any problems with "call function name" before, though, I don't know what the problem is.

@chafari: That code doesn't solve anything. His point is that he wants to use the "call function name" function.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jul 2013 19:44
Quote: "@chafari: That code doesn't solve anything. His point is that he wants to use the "call function name" function."


I'm gettin ol...stupid !!

I'm not a grumpy grandpa
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 4th Jul 2013 07:25 Edited at: 4th Jul 2013 07:30
I don't crash, and I get the expected "hello".



HOWEVER, it's the second function that's crashing;



I've never seen a "data" statement tucked inside a function before. Is this a normal thing to do? In further testing, even moving the "Data" statement out of the function, and into either the main program, or even a subroutine still crashes the application.

Hmm, I wonder what's going on here... EDIT: The plot thickens!




Seems we have a bug here!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jul 2013 13:31
The CrashOn....txt file says:




Hopefully that means something to someone.
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 4th Jul 2013 14:39
As a work around, I would encourage the use of the Matrix Utilites DataFile commands, rather than the default DBPro Data command. It's a little bit more work to get started, but much more flexible & functional.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Jul 2013 15:30
It may be that the function name table is expected to start at a certain offset that is changed if any custom data is added to the executable (as I assume are the point of the data / read commands).

The same problem (immediate close without any indication of a crash) happens if you use a function number to retrieve the function pointer as well.


"Why do programmers get Halloween and Christmas mixed up?"
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 4th Jul 2013 16:01
Data statements should not go in functions.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Jul 2013 17:19
Data statements should not be used. lol

Use external data files instead. (Not a coding essential, but my personal preference.)

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jul 2013 20:22
Quote: "Data statements should not go in functions."


Not relevant - the same problem occurs if you put them in the main code.

Quote: "Data statements should not be used. lol"


Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 5th Jul 2013 05:40
Quote: "Data statements should not be used. lol

Use external data files instead. (Not a coding essential, but my personal preference.)"

lol what is this the 80's?
That command was awful even when I was running QBasic 20 years ago.

pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 5th Jul 2013 18:35
There was code posted a while back on making a grid. The code used the DATA statements. This was fine until I began using the "call function name" commands.

I am using a different way to make the grid, so no more DATA statements.

Still, this issue is a bit of a bugaboo for the unwary.
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 7th Jul 2013 08:28
Haven't checked how data blocks are implemented in DBpro, but suspect data chunks might affect how the 3rd party call function name resolves the address of function.

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 22nd Oct 2013 05:06 Edited at: 22nd Oct 2013 08:33
I'm getting older & stupider... what am I missing with the below, as I can't get it to add the numbers. Perhaps Function Returns don't work with these Matrix1 Utility commands? What am I forgetting here!?




EDIT: A little tinkering gave some results;




Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 22nd Oct 2013 11:52
May I ask why you try to call a function with less arguments than it expects?
To me that just sounds like it's bound to fail...
To be technical it may be that it pushes the return value to your last argument's address (that doesn't exist) or similar.


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 22nd Oct 2013 12:59
Well, using native DBPro functions, it's perfectly normal to drop some arguments off to change the way the stock-standard functions behave. I just figured this might be handy if the same theory could be applied to my own functions, and thought that this might be the way to do it.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 22nd Oct 2013 15:11
Like the built in ones?
Those support function overloading, but you are in reality calling different functions depending on the number of arguments you provide.
Other languages like C++ offer default parameters, these are parameters that, unless explicitly set when calling a function, will be automatically assigned default values (as defined when writing the function itself).

This accomplishes what you want, but it's rather round-about to write:



"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 23rd Oct 2013 01:58
Thanks for the help Rudolpho, between the help received from you & IanM, I'm starting to make sense of what's required to run with this technique.

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

Login to post a reply

Server time is: 2026-07-07 01:54:23
Your offset time is: 2026-07-07 01:54:23