;-- TIME_STAMP 2018-06-22 11:38:22 v 0.1 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Number ; Description ...: Works like "Number()", but avoids to convert a string to number 0! ; Syntax ........: _Number($_Expression, $_Flag) ; Parameters ....: $_Expression - An expression to convert into a number. ; ...............: $_Flag - Can be one of the following: ; ...............: $NUMBER_AUTO (0) = (default) the result is auto-sized integer. ; ...............: $NUMBER_32BIT (1) = the result is 32bit integer. ; ...............: $NUMBER_64BIT (2) = the result is 64bit integer. ; ...............: $NUMBER_DOUBLE (3) = the result is double. ; Return values .: Success The converted number, if $_Expression is a number or starts with a number. ; ...............: Failure Empty string, sets @error = 1 $_Expression is a string or starts with a string. ; Author ........: BugFix ; Remarks .......: In contrast to Number(), you get only a number, if $_Expression is a number or starts with it. ; ...............: Because 0 is also a number, Number() give unclear results: ; ...............: Number("foo") returns 0. Number("0") returns also 0. "0" converts to the real number 0, but "foo" also?? ; =============================================================================================================================== Func _Number($_Expression, $_Flag=0) If StringRegExp($_Expression, '\A(\D+)') Then Return SetError(1, 0, '') Else Return Number($_Expression, $_Flag) EndIf EndFunc ;==>_Number