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 / problems with the IF statement...

Author
Message
Rais
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 10th Jul 2003 23:26
Im haveing problems comparing 2 variables... if you have a look at line 37 (if Doors(zz).dooropen=true) it doesnt work
if i change the code to 'if 1=Doors(zz)' then it works...
Its starnge as the variable true is set to 1 and is global...
Any idea's on why this happens?

Cheers
set display mode 1024, 768, 32
sync on
sync rate 70
randomize timer()

`Variables...
global true as boolean : true=1
global false as boolean : false=0

TYPE Door
DoorOpen as byte
DoorTimer as integer
ENDTYPE

global dim Doors(100) as Door
_game()
end

Function _game()
ink RGB(255,255,255),rgb(0,0,0)
for zz=1 to 6
Doors(zz).doortimer=(timer()/100)+(rnd(60)+30)
Doors(zz).dooropen=rnd(true)
next zz

do
cls
time=timer()/100
text 100,100,"Time: " + str$(time)
for zz=1 to 6

text 100,100+(zz*20),"DoorTimer: " + str$(Doors(zz).doortimer)
text 100,110+(zz*20),"DoorOpen: " + str$(Doors(zz).dooropen)

if Doors(zz).doortimer
Rais
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 10th Jul 2003 23:29
hmm. new to these boards... lets try posting the code again

Vulcan Omega
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United Kingdom
Posted: 11th Jul 2003 00:48
Hi there,

I think there are some problems with Globals with the latest Upgrade 4.1, but I think it has been fixed for Upgrade 5. Though someone else will need to confirm this.

I hope that helps ya.

Vulcan Omega is closer than you think !
http://www.vulcan-omega.co.uk/
Rais
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 11th Jul 2003 01:27
Ahhh... Thanks...
Just reading some other posts in the snippets section, someone was saying about using pointers instead of globals... Think i will have to read up a little.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Jul 2003 20:21
I have no problems with globals - I do have problems with byte/boolean/word values though.

I simply use integers for everything at the moment - they obviously take up more room, but they also seem to be faster.

Login to post a reply

Server time is: 2024-11-24 23:04:54
Your offset time is: 2024-11-24 23:04:54