// =========================================================================== // 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 endString(string $s, int $count) // // // string : last $count characters of $s // // // This procedure returns the last $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. // // // endString("abc", 1); // // Result: c // // // endString("abc", 8); // // Result: abc // // // endString("abc", 0); // endString("", 3); // // // // global proc string endString(string $s, int $count) { string $out; int $sLength = size($s); if (($count > 0) && ($sLength > 0)) { if ($count > $sLength) { $count = $sLength; } $out = substring($s, $sLength - $count + 1, $sLength); } return $out; }