AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get size of a certain dimension of an array (https://forums.alliedmods.net/showthread.php?t=82453)

Particlman 12-23-2008 15:58

Get size of a certain dimension of an array
 
Is there a way in pawn to get the size of one of the dimensions of an array.

I want to get how long the 2nd dimension is, so if I want to add a new rank/level I wouldn't have to have the RANKS[][MAXRANKS][] variable in there that I would have to edit each time.It would just edit the maxranks for me.
Obviously if it is not possible it is one little number I would have to change to add a new rank so no big deal.

PHP Code:

new const RANKS[][][] = {
    {
"Civilian""Recruit""Recruit"},
    {
"Civilian""Private""Private"},
    {
"Civilian""Private First Class""Private First Class"},
    {
"Civilian""Specialist""Lance Corporal"},
    {
"Civilian""Corporal""Corporal"},
    {
"Civilian""Sergeant""Sergeant"},
    {
"Civilian""Staff Sergeant""Staff Sergeant"},
    {
"Civilian""Sergeant First Class""Gunnery Sergeant"},
    {
"Civilian""Master Sergeant""Master Sergeant"},
    {
"Civilian""Sergeant Major""Sergeant Major"}



Arkshine 12-23-2008 16:16

Re: Get size of a certain dimension of an array
 
Using your exemple :

sizeof RANKS will return 10
sizeof RANKS[] will return 3

Particlman 12-23-2008 17:44

Re: Get size of a certain dimension of an array
 
I love how helpful this place is, and how fast people respond to questions.

Thanks for the help


All times are GMT -4. The time now is 09:07.

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