3d array
#8

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
Your method is also bad because the compiler won't know exactly what you are doing. There won't be any error/warning in case you do anything with no logic. Example:
pawn Код:
g_OffRoad[ 0 ][ 500000 ]
Also, as I said before, the first dimension should be the number of rows (and it is) and the second dimension should be the number of human-readable columns (in your case it isn't). You can't access it like this:
pawn Код:
g_OffRoad[ 0 ][ 0 ] // name in index 0 with additional dimension for each character - nope
g_OffRoad[ 0 ][ 1 ] // value in index 1 - nope
Well, duh! That's why enumerators are commonly used for the last dimension, if it worked by simply placing a consecutive number there, then there would be no use for enumerators being used with arrays (in this particular scenario). Simple arrays like that behave that way so you can access individual cells; otherwise, you could only retrieve the whole set of characters.

That's also why the size of enumerators with elements that have more than one cell are always larger than the actual number of columns (counting by 1).

And the reason behind doing enum_name:1, enum_name:2, etc. in the index where the enumerator was placed when declaring the array as an alternative to not use the name of the elements in the enumerator.

I was only explaining to the thread author regarding to why a 3rd dimension isn't needed. But I get where you are coming from since I used 'column', it technically defines the column if you insert the right index, but I guess I could have used 'cell' instead.

-----

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Alright, I will use your method. Thank you.
I'm not sure what method you are talking about, but this is the most common one:

pawn Код:
enum e_array
{
    string[144],
    integer
};

new array[][e_array] =
{
    {"hello buddy", 5000},
    {"something", 2000}
};

main()
{
    printf("%s %d", array[0][string], array[0][integer]);
}
This is really basic (I see people that are new to PAWN even create arrays this way), I thought you knew about it already. So I just felt the need to point out why a 3rd dimension isn't needed.
Reply


Messages In This Thread
3d array - by GoldenLion - 03.01.2017, 22:55
Re: 3d array - by IstuntmanI - 03.01.2017, 23:07
Re: 3d array - by GoldenLion - 03.01.2017, 23:37
Re: 3d array - by SickAttack - 04.01.2017, 00:01
Re: 3d array - by GoldenLion - 04.01.2017, 00:47
Re: 3d array - by IstuntmanI - 04.01.2017, 01:23
Re: 3d array - by GoldenLion - 04.01.2017, 01:52
Re: 3d array - by SickAttack - 04.01.2017, 15:45
Re: 3d array - by GoldenLion - 04.01.2017, 16:21

Forum Jump:


Users browsing this thread: 2 Guest(s)