forums

TNT Basic Forums > Programming Q&A
shared arrays
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-06-2004 00:22

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

can you share arrays between procedures?
i would have assumed yes since you can share strings, but when i do i get an error that highlights the size of the array and says "expected a variable"
am i doing somthing wrong?

03-06-2004 00:59

Posted by:
DanLurie

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

Click Here to Email DanLurie   Find more posts by DanLurie

What's your code look like?

03-06-2004 01:07

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

the offending part goes somthing like this:

shared int maxShots
shared int shots[maxShots]

two errors are returned the first saying maxShots isn't a variable the other saying the closing square bracket is a syntax error. i tried dimensioning the array in an initialization procedure but i still get the same problem

here is the actual procedure:

procedure testForCollisions()
'shared variables
shared int ballSprite, batSprite
shared int nMobileBlocks, maxAmmo, maxShots
shared int blockSprite[nMobileBlocks]
shared int ammoSprite[maxAmmo]
shared int shotSprite[maxShots]
shared float ballX, ballY
'local variables
int i
.
.
.
end proc

i get six errors from this.

03-06-2004 03:44

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

All you have to do is leave the brackets empty in the shared int line; the dimensions are retained in the array variable:

int array[10]

procedure ShareArray()
shared int array[]
end proc

03-06-2004 03:54

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

oh, cool. thanks

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.