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 Discussion / some problems using function

Author
Message
freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 29th Jan 2003 01:05
Hi,

I've made a function but it doesn't do exactly what I want.
I intended to make a function to print some text on the bottom of the screen, but nothing happens.

Anyone can help me? I didn't use functions before...

Here it is:

HAL
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 29th Jan 2003 01:41
looks like your allmost there. the main reason you can't see anything is because the variable's you set at the top are not global, meaning the function does not recognize them. you can either:
pass the variables to the function eg. statusbartext("Press ENTER to let Player"+str$(beginplayer)+" start dealing",settings_xres,settings_yres).
make them global eg. dim settings_xres(1):settings_xres(1)=1152
or set them in the function making them local eg.
freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 29th Jan 2003 01:58
make them global eg. dim settings_xres(1):settings_xres(1)=1152

so you mean arrays are always global?

thanks for help anyway!

freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 29th Jan 2003 02:04
just tested, it works fine!

the array solution is the best one in this case

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Jan 2003 03:59
arrays are global within DarkBasic unless you place them within a Function, then they become private.

anything that is used within the function they can be used int - anything outside of it they can't

Anata aru kowagaru no watashi!
freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 29th Jan 2003 13:48
[B][I]unless you place them within a Function[/I][/B]

you mean that they are dimmed within the function in that case?

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia

Login to post a reply

Server time is: 2024-05-05 08:00:20
Your offset time is: 2024-05-05 08:00:20