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.

Author
Message
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 02:42
hello people,
i was wondering, is there by any chance...ummmmmm, i'll explain by an example
i made a function on a seperated DB program, and it has the code:
if mouseclick()=1 then goto main_menu
the (main_menu) label is on another separated DB program. so i #included the function program to the basic one, so an error occurs saying that no such label is being used. can this be solved? without binding the two programs into one program.
thankx for advance.

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 10th Nov 2003 03:14
did you use quotes?

#include "filepath\file.dba"

Two words, moo.
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 03:31
i didnt understand that, what is it? or where do i find it?

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 10th Nov 2003 03:46
quotes are these ""
if you wanted to include a file in the SAME directory as the main program you use put

#include "file.dba"

if you wanted to include a file somewhere else on the drive you would type

#include "X:\file\path\file.dba"

do you understand now? make sure you typed everything in right

Two words, moo.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 10th Nov 2003 08:53
and if that doesn't work for you...

You can make it so that when the function ends, it returns a value,
IE:



then in your main program, have a check, IE;


Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 14:33
that didnt work thankx anywayz. i'm still trying for other solutions, if anyone can help me out dont hazitate!

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Nov 2003 14:43 Edited at: 10th Nov 2003 14:43
man, you can't do that, a function is treated like a seperate code block, all subroutie calls (goto, gosub) from inside a function cannot be linked to another subroutine outside that function! the only way to get out of a function is to use exitfunction or endfunction. The goto and gosub commands will only work if the subroutine your calling is within the functions limits.

i take it your doing is something like:

file1.dba
---------

function a()
if mouseclick()=1 then goto main_menu
endfunction

file2.dba
---------

#include file1.dba
a()
main_menu:

i guess the easiest way to get around that is using "exitfunction" rather than "goto main_menu"

HIH (hope i helped)

D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 14:55
that really blew everything!

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Nov 2003 16:13 Edited at: 10th Nov 2003 16:15
sorry

D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 17:00
well, i'm sure there's a way of solving this, its a major problem, but i gata find a solution. and hey! dont b sorry
thankx

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Nov 2003 19:00
what are u actually trying to do?

JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 10th Nov 2003 19:16
he is trying to include a file in with his program

Two words, moo.
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Nov 2003 19:22 Edited at: 10th Nov 2003 19:22
i know, i meant in more detail , like he had the code:

Quote: "if mouseclick()=1 then goto main_menu"


i take it your making a menu, and you want each of the menu fields to be handled seperately (or together) in a different function outside the main file?

D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 10th Nov 2003 21:08
no, i'm using a function(a separate DB file)for only a file selector, u know like choosing the level u want from a window. the window has two buttons, OPEN and CANCEL.
the main DB file #includes this function. the OPEN button was easy, it's just like "if mission_select1=1 then goto mission1", this was written on the main DB file. the problem is in the CANCEL button. when i press cancel it should get back to the main menu. i tried alot of things but it just wont work. i'll give u the code of the function, but its a lil messy! it's on the "source".
and here's the main program for the file selector:

thankx for trying to help.

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Nov 2003 22:48 Edited at: 10th Nov 2003 22:48
"if menu=1 then goto main_menu"

Where does the variable menu come from? If it's not used anywhere it'll be 0.

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
KNau
22
Years of Service
User Offline
Joined: 25th Nov 2002
Location: Canada
Posted: 10th Nov 2003 23:24
The "no such label" error means you are calling a subroutine that does not exist. Is the main_menu code used as a subroutine "main_menu:" or is it used as function "main_menu()"?

Subroutines (GOTOs and GOSUBs) are local to the function they are in and cannot be called from outside. So if the "main_menu" subroutine is in the primary .dba file you would not be able to call it from inside an #INCLUDEd file. You would have to return to your main code block and then call the subroutine from there.

http://www.canceriannewmedia.com
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 11th Nov 2003 00:51
"KNau" can u explain by code what u mean? a lil snippet would b fine. and my MAIN_MENU is a subroutine "main_menu:" on the primary file. and the "goto main_menu" is on the #included file (function). ofcorse an error would occure telling me that no such label is being used, so is there a way to avoid this?

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Nov 2003 01:00 Edited at: 11th Nov 2003 01:01
Call the function where you choose the map. Let the function return the map name or filename or whatever in case the user selected one or an empty string if the user pressed cancel. No from you main file either load the map or continue the main menu loop.

Like
mainmenu:
do
rem do menu checking here. If the user wants to select a map call the function:
result$ = SelectMap()
if result$ <> "" then gosub LoadMap
loop

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 11th Nov 2003 01:12
"empty", that's a cool solution, i've tried it but didnt work well. actually the file selector is an independant loop using a repeat until the user selects a map.

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Nov 2003 01:16
What does the selector do when the user presses Cancel?

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 11th Nov 2003 01:19
hey guys, u wont belive this!!!!! i cracked it!!!!!!
this is how it worked:

for the #included file, inside the loop:
1. check for mouse positions over the "cancel"
2. check for mouse click
3. if mouseclick()=1 then exit

for the main program, inside the repeat loop:
1.after all the if statements for mission selection put "goto main_menu"

TADAAAA problem solved, mission accomplished, situation under control again.
but thank alot guys for everything

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)

Login to post a reply

Server time is: 2025-05-21 16:24:10
Your offset time is: 2025-05-21 16:24:10