ID Problem.
#7

Quote:
Originally Posted by norton2
Посмотреть сообщение
If you go from 0 everything is ok, but you can not go from ID 1?
A PAWN array's index starts from 0. This means that if you do "new Array[2];", you will be able to access Array[0] and Array[1]. Any other cells won't have any memory allocated, so trying to access them will result in an error (Array[2], Array[3] etc). If, for some reason, you want to skip index 0 and start from 1, you have to declare your initial array 1 cell bigger, so if you have 2 elements that you want to store in this kind of array, you will have to do "new Array[3];". Then, you will be able to access them by "Array[1]" and "Array[2]". But this means that you will keep 1 cell of memory occupied but not used, which is not good practice. Sure, you can do this in a specific place where it would be way harder to do it correctly (starting from 0), but don't even think to do it everywhere.
Reply


Messages In This Thread
ID Problem. - by norton2 - 30.08.2015, 06:19
Re: ID Problem. - by Mariciuc223 - 30.08.2015, 06:40
Re: ID Problem. - by Logofero - 30.08.2015, 06:42
Re: ID Problem. - by norton2 - 30.08.2015, 06:46
Re: ID Problem. - by Mariciuc223 - 30.08.2015, 06:49
Re: ID Problem. - by Logofero - 30.08.2015, 06:51
Re: ID Problem. - by HazardouS - 30.08.2015, 08:13
Re: ID Problem. - by norton2 - 30.08.2015, 09:17
Re: ID Problem. - by Riversong - 13.09.2015, 15:27

Forum Jump:


Users browsing this thread: 1 Guest(s)