forums

TNT Basic Forums > Bugs!
If statement doesn't execute unless preceded by a print statement
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-06-2003 00:12

Posted by:
DanLurie

Location:
Earth>USA>New Jersey>Clifton>My Chair

Click Here to Email DanLurie   Find more posts by DanLurie

This is indescribably bizarre. If I precede my if block with a print statement everything works as normal. If I don't, it skips right over the thing.

12-06-2003 02:29

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Welcome to my world

The same thing has happened to me more than a few times, but I forget exactly what I did.
I seem to remember that I had to change the IF statements in some way...

Could I see your statement and comment on what its supposed to do?

Thanks
MapMaker

12-06-2003 12:25

Posted by:
DanLurie

Location:
Earth>USA>New Jersey>Clifton>My Chair

Click Here to Email DanLurie   Find more posts by DanLurie

Its inside a procedure, if that matters:

Procedure checkforcollisions()
int i
int lx,ly,ldx,ldy
float s,t,d


for i = 0 to 5

lx=lines[i,0]
ly=lines[i,1]
ldx=lines[i,2]-lx
ldy=lines[i,3]-ly

d=(ldx*pdy)-(ldy*pdx)

if d=0
break
end if


t=(px*ldy)+(ly*ldx)-(lx*ldy)-(ldx*pdy)
t=t/d

if t>0 and t<1 This is the block giving me trouble
beep

s=(px+(pdx)*t-lx)/ldx

print s,t


else
break
end if

next

px=px+pdx
py=py+pdy

end proc

12-06-2003 13:20

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Hmm
If I remember mine correctly, there were all comparative operators like yours.

Im not sure exactly how yours works or what its supposed to do, but I think my problems were in the fact that sometimes used a "<" or ">" symbol by itself, when infact it should have been a "<=" or ">=". You might want to check that.

Sorry I couldn't help more,
MapMaker

12-06-2003 20:34

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Could I see the could with the print? Sometime I have added some commands without even really realising ...

12-06-2003 20:36

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Or is it the "print s,t" line? What does , do in a print statement? I thought it was ; maybe it changes something?? I dunno you should check

12-06-2003 22:23

Posted by:
DanLurie

Location:
Earth>USA>New Jersey>Clifton>My Chair

Click Here to Email DanLurie   Find more posts by DanLurie

The comma means it inserts some space between the two variables its printing.

12-09-2003 21:52

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

Can you post the code with both with the print statement (so that it works) and the code without the print statement (so that it skips the if block). Then we can compare them and try and figure out what the problem is.

Cheers,

Mark

12-09-2003 22:04

Posted by:
DanLurie

Location:
Earth>USA>New Jersey>Clifton>My Chair

Click Here to Email DanLurie   Find more posts by DanLurie

---------------
Here is the code
---------------

Procedure checkforcollisions()
int i
int lx,ly,ldx,ldy'Starting point of the line in x and y, and the distance in x and y of the end point from the start point

float s=-1,t=-1,d=-1


for i = 0 to 5

lx=lines[i,0]
ly=lines[i,1]
ldx=lines[i,2]-lx
ldy=lines[i,3]-ly

d=(ldx*pdy)-(ldy*pdx)

if d=0
break
end if


t=((px*ldy)+(ly*ldx)-(lx*ldy)-(ldx*pdy))/d

'print t

if (t>=0) and (t<=1)
beep

s=(px+(pdx)*t-lx)/ldx

print s,t
end if


next

exit:

px=px+pdx
py=py+pdy

end proc

---------------
The print statement is commented out ('print t.) The if statement does not execute until you uncomment that line.

01-29-2006 23:13

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

I'm unable to reproduce this in TB 1.3.

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.