// =========================================================================== // 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. // =========================================================================== // // // // // // string startString(string $s, int $count) // // // string : first $count characters of $s // // // This procedure returns the first $count characters of the string $s. // If $count is zero or negative, then an empty string is returned. // If $count is greater than or equal to the number of characters in $s, // then the entire string is returned. // // // startString("abc", 1); // // Result: a // // // startString("abc", 8); // // Result: abc // // // startString("abc", 0); // startString("", 3); // // // // global proc string startString(string $s, int $count) { string $out; int $sLength = size($s); if (($count > 0) && ($sLength > 0)) { if ($count > $sLength) { $count = $sLength; } $out = substring($s, 1, $count); } return $out; }