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 / Recursion?

Author
Message
mr b
18
Years of Service
User Offline
Joined: 28th Aug 2006
Location:
Posted: 24th Feb 2007 04:05
Hi,
I have a mildly recursive function, and it isn't doing what I expect.

id as integer

TestId()

function TestId()
id = id + 1
message str$(id) ` display current value of id
TestId()
endfunction

id always equals 1 but I would expect it to increment.

Why is this?

Thanks
mr b
18
Years of Service
User Offline
Joined: 28th Aug 2006
Location:
Posted: 24th Feb 2007 04:27
Doh! I was missing the global scope specifier. Works as it should now.
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 24th Feb 2007 04:57
it is because you don't pass it through the function so its local to that call. You would have to either global it or make it a parameter and put it through the function.

Current Project - Zio Engine: RPG Engine and OMMORPG

Login to post a reply

Server time is: 2024-11-26 00:41:20
Your offset time is: 2024-11-26 00:41:20