forums

TNT Basic Forums > Bugs!
Procedures are eating my local vars..
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-09-2004 02:27

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

I might just have completely no understanding about how anything works, but I think I found a bug in local variables.


procedure procone()

int num
.
.
.
print sx[num],sy[num]
proctwo(sx[num],sy[num])
print sx[num],sy[num]

end proc


Procedure aibuild is:


procedure proctwo(int numx,numy)

int num

num = 100

end proc


This prints:


85,45
0,0


In my view, this means that the procedure sucessful 'eating' my local variables.

Is this supposed to happen?

Sorry if I'm just wasting forum space :/
MapMaker

02-15-2004 19:17

Posted by:
eric

Location:
earth

Click Here to Email eric   Find more posts by eric

Sorry Mapmaker, the local variable are only used locally hence the name local. your example would work fine if you used global variable, or used the "end proc(testResult)" which returns a local variable or look into shared variables.
Not bug I can see

02-15-2004 19:55

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Maybe...

Actually, I think you may have a point, MapMaker. If that code does that, I think it is a bug.
However, if there is more to the procedures that you left out, the problem might not be a bug.

What your results say are that sx[num] and sy[num] are changed- not that num itself was changed. Just add "print num" after you call the second procedure to see. Num should definitely be the same.

01-29-2006 14:08

Posted by:
Mark Tully

Location:
TNT HQ, England

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

I can't reproduce this, it's not a bug as far as I can see.

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.