AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with multi-dimensional arrays (https://forums.alliedmods.net/showthread.php?t=17015)

Blackhawk 08-24-2005 14:06

Help with multi-dimensional arrays
 
If i have got an array, let's say with two dimensions, something like
Code:
Testarray[5][5]
and i would like to clear out one dimension completely, i could say something like
Code:
Testarray[3] = {0,0,0,0,0}

My question is: is there a better way, so i don't have to give every single value of this dimension? I read about something i could say
Code:
Testarray[3] = {0, ...}
but it seems no to work as expectet. Someone my have a better idea?

Xanimos 08-24-2005 14:33

I cant understand what your asking talk to me on aim

Blackhawk 08-24-2005 15:13

Sorry, don't use AIM or IRC :)

My question is simple: I want to clear out(reset an entire ROW(?) of an array

Letzs say you have this simple array of 5*5 (as stated above) and filled with some values:
Code:

        0    1    2    3    4   
0      33  22  54    24  54
1      11  22  52    54  99
2      35  12  45    86  53
3      56  23  21    67  46
4      43  36  44    67  44

Now, if i use something like
Code:
Testarray[3] = {0,0,0,0,0}
on it, i wipe out the entire row. the Result would be like this:
Code:

        0    1    2    3    4   
0      33  22  54    24  54
1      11  22  52    54  99
2      35  12  45    86  53
3      0    0    0      0    0
4      43  36  44    67  44

My question was simple: Is there a more elegant way to perform the same action? As i have read in the Small/Pawn manual, you can say something like
Code:
Testarray[10] = {0, ...}
to set all 10 cells in Testarray to the value 0. But this didn't work for multidimensional arrays, at last not here - compiler error.

I hope i made myself a little bit more clear.
Thanks for your support.

Freecode 08-24-2005 15:25

Quote:

Originally Posted by Blackhawk
Now, if i use something like
Code:
Testarray[3] = {0,0,0,0,0}
on it, i wipe out the entire row. the Result would be like this:
Code:

        0    1    2    3    4   
0      33  22  54    24  54
1      11  22  52    54  99
2      35  12  45    86  53
3      0    0    0      0    0
4      43  36  44    67  44


Testarray[3] will look like this
Code:

      0    1    2    [3]
      #    #    #      \0

and to zero that out it will be like this
Testarray[3] = {0,0,0};
but Testarray[3] = {0,...}; should work. did u try it?

Blackhawk 08-24-2005 18:33

Quote:

Originally Posted by Freecode
Quote:

Originally Posted by Blackhawk
Now, if i use something like
Code:
Testarray[3] = {0,0,0,0,0}
on it, i wipe out the entire row. the Result would be like this:
Code:

        0    1    2    3    4   
0      33  22  54    24  54
1      11  22  52    54  99
2      35  12  45    86  53
3      0    0    0      0    0
4      43  36  44    67  44


Testarray[3] will look like this
Code:

      0    1    2    [3]
      #    #    #      \0

and to zero that out it will be like this
Testarray[3] = {0,0,0};
but Testarray[3] = {0,...}; should work. did u try it?

This works, but i need the same on multidimensional arrys (as the topic says :) )

Defined was Testarray[5][5], so Testarray[3] selects 5 unique values, not just one. My 'problem' is: I wanted to know a smart way to 'nullify' a whole line in a multidimensional array, no matter how big the array might be, ie 32 Lines of 50 values.Testarray[3] = {0,...} works perfectly on single dimensional arrays.


All times are GMT -4. The time now is 14:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.