• Advertisement
Sign in to follow this  

array of object handles

This topic is 4335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have declared an object class myself. now i wanted to have an array of them, but cannot seems to be able to do it correctly. srObject@ Object_shape; //1 object srObject[] @list_of_Objects (100); //Error: only objects have contructors

Share this post


Link to post
Share on other sites
Advertisement
It should be:


srObject@[] list_of_Objects(100);


You were actually declaring an object handle to and array of srObjects. [wink]

Share this post


Link to post
Share on other sites
i tried that and it is throwing "Error : Expected data type"
i am using 2.5.0c

srObject@[] list_of_Objects(100);

Share this post


Link to post
Share on other sites
I've been trying to reproduce your problem, and so far everything works as it should without any compiler errors. I can compile the following script without any problems:


string@[] c(10);


Perhaps it has to do with how you registered the srObject type. Can you show us how you've registered the type, including the behaviours? Also, can you show us the exact error messages that you're getting, as well as the script lines they refer to?

Regards,
Andreas

Share this post


Link to post
Share on other sites

interesting.....

i tried to use your example, and string is registered per AS sample.

string@[] c(10); //this is a line 27


error message returned:
as (27, 13) : Error : Expected data type

Share this post


Link to post
Share on other sites
Include the <vector> header file and use vector stl.

std::vector<srObject@> object_array;

Now resize the vector of objects to what ever size N you want.

object_array.resize(N);

Now you can use the vector just like an array.

object_array[0], object_array[1], object_array[2], .... , object_array[N]

Just make sure that you boundary check when you are tring to access an element in the vector/array.

Just make sure that you clear the vector, and free up the memory being used by the Objects in the vector/array.

Share this post


Link to post
Share on other sites
And I am left wondering WTF that has to do with Angelscript...

Share this post


Link to post
Share on other sites
I'm also wondering what the @ token means in C++. Is this something available in a newer version of C++ that I'm not aware of? [wink]

iram:

Which character is on the 13th column? Is it the c? Or @? Or []?

Are you declaring the array as a global variable? It could be that it would be parsed differently. I'll test that.

Regards,
Andreas

Share this post


Link to post
Share on other sites
I think it's in C# or C++/CLI. I don't really know, I'm strictly a C++ guy.

Share this post


Link to post
Share on other sites

i found that the problem appears if you declare as global variable.
but in a method, it is working.

string@[] c(10); //the 13 column is referring to 1 in number 10.


Share this post


Link to post
Share on other sites
Ah, then this has already been fixed in the latest WIP, I just tried that and it worked ok. [smile]

I won't be releasing any new versions of 2.5.0, as 2.6.0 is coming around the corner. I'll probably be able to release 2.6.0 already this weekend.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
Ah, then this has already been fixed in the latest WIP, I just tried that and it worked ok. [smile]

I won't be releasing any new versions of 2.5.0, as 2.6.0 is coming around the corner. I'll probably be able to release 2.6.0 already this weekend.

Regards,
Andreas


Awesome

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement