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.

Years of Service
User Offline
Joined: 21st Oct 2015
Location: Lisbon
Posted: 6th Dec 2018 14:42
Is it safe to use function pointers?

I have tried with Matrix1 Plug-ins and on first test I got a bug.

The first letter of "WAIT KEY" doesn't show
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 6th Dec 2018 23:37
I ran the code you listed and it ran fine for me. I'm not sure why you would want to use a pointer to a function to call it. Typically, functions are used for passing variables to them and receiving a value back. In your example, nothing is passed and nothing is returned. I don't see any advantage to simply calling the function via a pointer. What is it that you are trying to accomplish with the function call?

So many games to little time.
DBPro Master
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Dec 2018 23:48 Edited at: 8th Dec 2018 14:45
The example is very simple for testing, you would call by ptr for things like call backs and abstractions, places where the code calling the function doesn't need to know what specific function it is calling, and where the function it is calling is variable. It is extremely useful.

I've encountered that missing first character before also, but I'm not certain if call function ptr was the cause, and it doesnt always drop the letter. It's an odd bug that is a pain to deal with.

You might try text instead of print, but there is definitely some strange behavior with call function ptr and call function name.

I had to stop using them because they cause graphical errors with AdvLighting

Now I am emulating call function name with a dispatcher function which is a select case of functions that can be called. It's a hack, but it works without the bugs

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Derek Darkly
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 7th Dec 2018 23:50
Code worked fine for me! =)
But even if it didn't, one could devise a simple workaround for calling the correct function at the correct moment of a program.
I find that half of all DBPro functions are for convenience only, and are not really pertinent to coding, For, me the challenge is in the control.

Send your parents to noisy sprite demo hell... enter the D-Zone

Login to post a reply

Server time is: 2023-12-05 11:54:24
Your offset time is: 2023-12-05 11:54:24