// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // // // // int stringArrayRemoveAtIndex(int $index, string[] $list) // // // Remove the entry at $index from the string array $list. // // // int $index The index of the element to remove from $list. // string[] $list A list of string values. // // // int : Returns false if $index was out of range and true on // success. // // // string $array1[] = {"item1", "item2", "item3"}; // // Result: item1 item2 item1 // // stringArrayRemoveAtIndex(1, $array1); // // Result: 1 // // print $array1; // // Result: item1 item3 // // // // global proc int stringArrayRemoveAtIndex( int $index, string $list[] ) { int $i; string $result[]; int $len = size( $list ); // Check for a valid index. // if ( $index >= $len || $index < 0 ) { return( false ); } // Copy any entries prior to $index. // for ( $i = 0; $i < $index; $i++ ) { $result[$i] = $list[$i]; } // Copy any items which come after $index. // for ( ; $i < $len - 1; $i++ ) { $result[$i] = $list[$i + 1]; } // Copy the result to the list argument. // $list = $result; return( true ); }