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.

DarkBASIC Professional Discussion / Function not being called

Author
Message
eatthistim
12
Years of Service
User Offline
Joined: 11th Jun 2014
Location:
Posted: 11th Jun 2014 23:17 Edited at: 12th Jun 2014 17:52
hi guys,
i have recently started learning DarkBasic pro and have been making some simple programs to get used to the basic commands, however i have been having trouble with one of the functions that i have created coming up with a syntax error on the line that it is called whenever i try to compile the code. i cannot see any problems with the code myself but being new to the language i may be missing something glaringly obvious.
i welcome any help that you guys can give.

function startup()
input "Choose an app: 1.Counter 2.Countup 3.Countdown (1/2/3)",appchoice$
if appchoice$ = "1"
cls
counter()
end
endif
if appchoice$ = "2"
cls
print "2"
wait 1000
end
endif
if appchoice$ = "3"
cls
countdown()
else
print "Please choose a valid option"
wait 2000
cls
startup()
endif
endfunction



function countdown()
y=0
cls
set text size 30
input "Choose a number to count down from: ",choice
x=choice
cls
set text size 100
ink RGB(255,0,0),0
set cursor 450,325
print x
wait 1000
do
if x=y
final3()
endif
x=x-1
cls
set cursor 450,325
print x
wait 1000
loop
endfunction


Edit: thanks for the help guys, I looked back through my code more carefully and found that I had completely forgotten to put the end function at the end of a completely different function
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 12th Jun 2014 00:46
There doesn't seem to be anything that shouldn't run in the code you posted, it must be something else.
Please use the code button for posting code, you just press it, paste your code in, then press it again.
eatthistim
12
Years of Service
User Offline
Joined: 11th Jun 2014
Location:
Posted: 12th Jun 2014 00:58
i thought i did use the code button (my bad)
I have tried putting a different function in place of the one that isnt working and that worked fine so i have no idea what is going on
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jun 2014 01:19
Where is the code for the counter() function?

Also,

1. did you really intend to call the function startup() recursively?

2. did you really intend to end the program with options 1 and 2?



Powered by Free Banners
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 12th Jun 2014 17:35
Can't tell without more info but A few things you should be aware of. The little red highlighter doesn't always stop on the line with the error on it. It seems to have a habit of skipping onto the next line. Secondly with this language style it's worth warning that functions need to be isolated from the main flow to prevent a 'run into declaration' error. I don't know if that's the problem but it is something that people who have come from other languages can trip up on.

Login to post a reply

Server time is: 2026-07-06 02:53:26
Your offset time is: 2026-07-06 02:53:26