Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TraderTom, Akow), 1,388 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
handle function may not be working properly #156585
09/23/07 21:41
09/23/07 21:41
Joined: Oct 2006
Posts: 106
i_program_games Offline OP
Member
i_program_games  Offline OP
Member

Joined: Oct 2006
Posts: 106
I used to use function handles extensively until lite-C. I have tried every way possible and have read every piece of documentation and still can't resolve my issue. The handle function appears to give me the SAME value regardless of what function or action I give it. Here is an example of what I am trying to do:

action pAction();//pointer to an action

action myAction()
{
beep();
}

var hMyAction = handle(myAction);//This will return the SAME value regardless of what function or action it receives.

pAction = ptr_for_handle(myAction);

pAction();//Crashes here and I believe it's because of the handle


Chaos is a paradox consistently inconsistent.
Re: handle function may not be working properly [Re: i_program_games] #156586
09/24/07 11:27
09/24/07 11:27
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
This code will crash anyway because "myAction" is not a handle. You probably meant "hMyAction".

But that wouldn't work either because there is no ACTION object in lite-C. That was C-Script only, lite-C uses normal C functions.

So, correct is:

pAction = myAction;

and not

pAction = ptr_for_handle(myAction);

Re: handle function may not be working properly [Re: jcl] #156587
09/25/07 05:32
09/25/07 05:32
Joined: Oct 2006
Posts: 106
i_program_games Offline OP
Member
i_program_games  Offline OP
Member

Joined: Oct 2006
Posts: 106
Ok, so I've done this and it crashes on my PC but not my laptop.

//prototype
function test_function();

#define TEST_FUNCTION 0
function pFunction(); //function pointer
function* pFunctions[1]; //array of function pointers

pFunctions[TEST_FUNCTION] = test_function; //assign function pointer to array

function test_function()
{
beep();
}

function test_event()
{
pFunction = pFunctions[my.skill50]; //get our stored pointer index via skill variable
pFunction(); //CRASHES HERE ON MY PC BUT NOT THE LAPTOP
}

action test_action()
{
my.emask = ENABLE_CLICK;
my.event = test_event;
my.skill50=TEST_FUNCTION;
}


Chaos is a paradox consistently inconsistent.
Re: handle function may not be working properly [Re: i_program_games] #156588
09/25/07 06:24
09/25/07 06:24
Joined: Oct 2006
Posts: 106
i_program_games Offline OP
Member
i_program_games  Offline OP
Member

Joined: Oct 2006
Posts: 106
FIXED IT!

I needed to put this part:

pFunctions[TEST_FUNCTION] = test_function; //assign function pointer to array

Inside of a function so I put it into main().

Thanks for the help!


Chaos is a paradox consistently inconsistent.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1