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 / calling a function in a function

Author
Message
evan
21
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United Kingdom
Posted: 18th Jun 2003 01:54
I read that u shoud'nt call another function from
within a first function,but i tried this and there
did'nt seem to be any problems.
Is it just good practise not to do this
or are there any other reasons not to ?

Thanks.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jun 2003 01:57
There should be no problems as long as all the functions end properly, and you dont try and jump out of them.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jun 2003 05:51
You also have to make sure that the function being called has been declared before the one it was called from. If you see what I mean...

TDK
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 19th Jun 2003 22:58
it can have problems, it is possible to eat the stack and crash your computer

THIS WILL CRASH YOUR COMPUTER*****************************************

first()

function first()
print "argh!"
second()
endfunction

function second()
Print "no!"
sync
first()
endfunction

THIS WILL CRASH YOUR COMPUTER ***************************************

it`s not realy a bug with DB, C++ and most other languages have the same problem, its just that this issue is often hidden from the user by the programs we normaly use, you can call routines recursively (some fill algorythms do so) but since the stack space on a computer is always limited and you can run out of the stack at any time then it is not a good idea to do so, thats why the new matrix functions will be so useful when they get sorted properly, you can use those for recursive code without crashing the system, (though you may run out of memory.

Mentor.

Login to post a reply

Server time is: 2024-11-24 18:56:34
Your offset time is: 2024-11-24 18:56:34