VS:ValidNumStr

From Vectorworks Developer
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Function ValidNumStr returns TRUE if the specified string can be converted into a numeric value. If TRUE, the numeric value is returned.

FUNCTION ValidNumStr(
str :STRING;
VAR value :REAL) : BOOLEAN;
def vs.ValidNumStr(str):
    return (BOOLEAN, value)

Parameters

str STRING String value to be checked for numeric validity.
value REAL Numeric value converted from input string.

Return Value

Returns TRUE if specified string can be converted into a numeric value.

Remarks

(Joel Sciamma, 2007.01.13):

  • Returns TRUE if the specified string can be converted into a numeric value and places the value in the REAL parameter.
  • Returns FALSE if the specified string can not be converted into a numeric value and places zero in the REAL parameter.

Example

VectorScript

CASE Item OF
{// OK Button //}
1:BEGIN
IF ValidNumStr(GetField(4),value) THEN BEGIN
Done:=TRUE;
replaceValue:= GetField(6);

IF ItemSel(9) THEN textMode:=2;
IF ItemSel(10) THEN textMode:=4;
IF ItemSel(11) THEN textMode:=8;
IF ItemSel(12) THEN layerMode:=16;
IF ItemSel(13) THEN layerMode:=32;
IF ItemSel(14) THEN caseMode:=1;
END
ELSE SysBeep;
END;

Python

str = '5m + 5cm'
ok, num = vs.ValidNumStr( str )
vs.AlrtDialog( num )

Version

Availability: from All Versions