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 / Can I use labels inside function??

Author
Message
Lord Danath
21
Years of Service
User Offline
Joined: 29th Aug 2003
Location:
Posted: 26th Sep 2003 01:01 Edited at: 26th Sep 2003 01:03
I wonder if I can use a gosub inside a function. The reason is that I need to transfer parameters in the function, and that function must call a subroutine, but it didnt work. Can I do that??

It is time to say hello...
HELLO
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Sep 2003 01:16
You should be able to GOSUB from a function, because it has a return point. It's only like calling another function.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Sep 2003 21:11
but you may have a variable Scope problem there. Local variables in the function go out of scope when the function ends.

-RUST-
KNau
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: Canada
Posted: 27th Sep 2003 00:20
Yes, you can call subroutines from within a function as long as that subroutine is contained in the same .dba file. If you are using a function that has been #INCLUDED (which you should be) then it would look something like this:

FUNCTION my_function()

REPEAT
IF SPACEKEY() = 1 THEN GOSUB space_sub
UNTIL RETURNKEY() = 1

EXITFUNCTION

space_sub:

RETURN

ENDFUNCTION

You have to use an ENDFUNCTION for the true ending of your code block and EXITFUNCTION to leave the function itself. All variables are localized to that code block, though.

http://www.canceriannewmedia.com

Login to post a reply

Server time is: 2024-09-21 01:09:08
Your offset time is: 2024-09-21 01:09:08