{"name":"resize","operator":null,"title":"resize","type":"command","url":"https://community.bistudio.com/wiki/resize","revid":364809,"updated":"2024-06-15T13:16:01Z","groups":["Arrays"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.75"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.75"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Changes the size of the given array. The command does not return new array, it resizes the source array to the desired number of elements.\nIf the new size is bigger than the current size, the new places are filled with nil. The alternative syntax allows to fill resized positions with a given value. Array and HashMap values are copied.","syntaxes":[{"syntax":"array resize count","since":null,"effect":null,"exec":null,"params":[{"name":"array","type":"Array of Anything","optional":false,"default":null,"description":null,"types":["Array","Anything"],"since":null,"text":"array: Array of Anything"},{"name":"count","type":"Number","optional":false,"default":null,"description":"the new array size","types":["Number"],"since":null,"text":"count: Number - the new array size"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"array","types":["Array","Anything"]},"right":{"text":"count","types":["Number"]}},{"syntax":"array resize [count, fill]","since":"arma3 2.10","effect":null,"exec":null,"params":[{"name":"array","type":"Array of Anything","optional":false,"default":null,"description":null,"types":["Array","Anything"],"since":null,"text":"array: Array of Anything"},{"name":"count","type":"Number","optional":false,"default":null,"description":"the new array size","types":["Number"],"since":null,"text":"count: Number - the new array size"},{"name":"fill","type":"Anything","optional":false,"default":null,"description":"value to fill added positions","types":["Anything"],"since":null,"text":"fill: Anything - value to fill added positions"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"array","types":["Array","Anything"]},"right":{"text":"[count, fill]","types":["Array"]}}],"examples":[{"text":"```sqf\n_arrayNum = [0,1,2,3,4];\n_arrayNum resize 2; // _arrayNum is now [0, 1]\n_arrayNum resize 5; // _arrayNum is now [0, 1, nil, nil, nil]\n```","code":["_arrayNum = [0,1,2,3,4];\n_arrayNum resize 2; // _arrayNum is now [0, 1]\n_arrayNum resize 5; // _arrayNum is now [0, 1, nil, nil, nil]"]},{"text":"```sqf\nprivate _array = [0, 1, 2];\n_array resize [5, -1]; // _array is now [0, 1, 2, -1, -1]\n\nprivate _array = [0, 1, 2];\n_array resize [1, -1]; // _array is now [0]\n\nprivate _array = [0, 1, 2];\n_array resize [4, \"something\"]; // _array is now [0, 1, 2, \"something\"]\n```","code":["private _array = [0, 1, 2];\n_array resize [5, -1]; // _array is now [0, 1, 2, -1, -1]\n\nprivate _array = [0, 1, 2];\n_array resize [1, -1]; // _array is now [0]\n\nprivate _array = [0, 1, 2];\n_array resize [4, \"something\"]; // _array is now [0, 1, 2, \"something\"]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["set","reverse","deleteAt","deleteRange"],"notes":[{"user":"DreadedEntity","date":"2014-11-13T06:26:00Z","text":"Use this number to resize the array to the number of elements desired, not the desired index of the final element.\n\nresize cannot be used to create a new array."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Introduced with Operation Flashpoint version 1.75","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}