Gamestudio Links
Zorro Links
Newest Posts
SGT_FW
by Aku_Aku. 11/30/26 08:19
Removing outliers from files
by JeyKey II. 11/29/26 10:01
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (JeyKey II, AndrewAMD, EvanTJ), 12,229 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Functions calling themselves #166561
11/08/07 21:41
11/08/07 21:41
Joined: Sep 2007
Posts: 14
X
xykynan Offline OP
Newbie
xykynan  Offline OP
Newbie
X

Joined: Sep 2007
Posts: 14
I created the following function and my program crashed. If it is not possible for functions to call themselves, what would a reasonable workaround be?

void move_tab (MENU_TAB* m, int a)
{
int j = 0;
int k = 0;
while (k <= m->pan_num)
{
m->panels[k]->pos_y += a;
k += 1;
}
k = 0;
while (k <= m->tex_num)
{
m->texts[k]->pos_y += a;
k += 1;
}
k = 0;
while (k <= m->tab_num)
{
move_tab (m->sub_tabs[0], a);
k += 1;
}
}

Thanks in advance!

Re: Functions calling themselves [Re: xykynan] #166562
11/08/07 22:30
11/08/07 22:30
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Functions calling themselves are called recursive functions. Might be of help for you when researching.

Anyhow, I think it's relating to how you pass your pointer to the function, maybe resulting in an infinite loop at the first function. Try without the loops but just a small counter (and global counter variable), does it still crash? Try to think of more testcases to get the piece of code causing the crash. Because recursive functions work fine, I did it.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Functions calling themselves [Re: Joozey] #166563
11/08/07 22:33
11/08/07 22:33
Joined: Sep 2007
Posts: 14
X
xykynan Offline OP
Newbie
xykynan  Offline OP
Newbie
X

Joined: Sep 2007
Posts: 14
Thanks for the fast response!

I went through some tests and it turns out I had an empty pointer in one of my structs.
Sorry for the trouble.

Re: Functions calling themselves [Re: xykynan] #166564
11/08/07 22:34
11/08/07 22:34
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands



Click and join the 3dgs irc community!
Room: #3dgs
Re: Functions calling themselves [Re: Joozey] #166565
11/08/07 23:18
11/08/07 23:18
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
Afaik all recursive functions can be written as iterative functions (loop) and it's faster.


Follow me on twitter

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

Gamestudio download | 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