// =========================================================================== // 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. // =========================================================================== // // // Creation Date: August 14, 1996 // // Description: // Process the numerical input. // // Input Arguments: // Numerical values (see scmh command for its syntax). // // Return Value: // 1 on success, 0 on fail. // global proc int numericalInput( string $value ) { // If the string is empty then there is nothing to do here int $stringLen = `size $value`; if ( $stringLen == 0 ) return 0; // Define the character used to mean "ignore this entry position" // string $ignoreEntryChar = "."; // Tokenize the value string // string $valueArray[]; int $numTokens = tokenize ($value, $valueArray); // Try to build up the proper string now // string $result; // scan for command flags // for ($i = 0; $i < $numTokens; $i++) { // Only need to add one flag to the result string if ($valueArray[$i] == "-a") { $result = (" " + $result + " " + $valueArray[$i]); } else if ($valueArray[$i] == "-r") { $result = (" " + $result + " " + $valueArray[$i]); } else if ($valueArray[$i] == "-q") { $result = (" " + $result + " " + $valueArray[$i]); } else if ($valueArray[$i] == "a") { // Put `-` in front of flag or command will complain $result = (" " + $result + " -a"); } else if ($valueArray[$i] == "r") { // Put `-` in front of flag or command will complain $result = (" " + $result + " -r"); } else if ($valueArray[$i] == "q") { // Put `-` in front of flag or command will complain $result = (" " + $result + " -r"); } } // scan for numbers string $numbers; // int $offset = 1; for ($i = 0; $i < $numTokens; $i++) { if ($valueArray[$i] == $ignoreEntryChar) { $result = (" " + $result + " -ignore " + $offset); $offset++; $numbers = (" " + $numbers + " 0"); } else if ($valueArray[$i] == "-a" || $valueArray[$i] == "a" ) { } else if ($valueArray[$i] == "-r" || $valueArray[$i] == "r" ) { } else if ($valueArray[$i] == "-q" || $valueArray[$i] == "q" ) { } else if ($valueArray[$i] == "") { } else { $numbers = (" " + $numbers + " " + $valueArray[$i]); $offset++; } } $stringLen = `size $numbers`; int $returnVal = 0; if ( $stringLen > 0 ) { $returnVal = !(catch(`eval( "scmh" + $result + $numbers )`)); } return $returnVal; }