forums

TNT Basic Forums > Feedback
returning values
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-03-2003 23:32

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

it would be convenient to be able to return multiple values from a procedure. i've got this procedure that finds the x distance and y distance a bullet needs to travel, but i can only return one value.

04-03-2003 23:35

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

that reminds me, it would also be nice if you could use 'move sprite' to move a sprite from one point to another instead of passing distances.

04-04-2003 10:36

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

go on, leave that "move sprite" function and work it out yourself with x and y... the first you do this, the less problems you' ll have after.

04-04-2003 10:38

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

And, yes, it would be nice if you could at least return an array (where you yould know, for example, that array[0] is the x, and array[1] the y).

04-04-2003 23:10

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

You know, even very professional software only allows one value. The problem, in my opinion is much more likely to be the Retun int thing.

Example:

Sprite 1,getX(),getY(),getImage()

Instead of your idea:

calculateSprite()
x=result int 1
y=result int 2
image=result int 3
sprite 1,x,y,image

or something like this

04-05-2003 09:37

Posted by:
Mark Tully

Location:
TNT HQ, England

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

Shared parameters

If we were to add this then the most logical way of doing it would be to allow returning values in the parameters passed to the function, perhaps by declaring them as shared parameters, eg:

int xx=0,yy=0
myCalc2Values(xx,yy)
print xx,yy

procedure myCalc2Values(shared int x,shared int y)
x=2
y=4
end proc

producing output
2,4

We'll probably add something like this later this year when we do the engine update - as well as adding the ability to return values from the procedure as a function:

eg:

int function squareInt(int val)
return val*val
end func

Or some syntax similar to that...

Cheers,

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.