SclExpr
Overview
The SclExpr command provides an alternate expression evaluation command to the expr command that is included as an integral part of Tcl.
Synopsis
SclExpr $Expression
Description
The expression parser used by SclExpr has been developed by GEOVIA and includes trigonometric functions that operate in degrees as well as radians as the degree trigonometric functions are often more convenient.
The complete range of functions and the syntax of the expressions that may be used for the SclExpr command can be found here.
Unlike other SclCommands that return an integer status value to indicate the completion status of the command, SclExpr returns a single value that is the result of the expression after evaluation.
Arguments
- Expression
Passed by value. A quoted string that contains the expression that is to be evaluated.
Examples
# add two numbers
set result [SclExpr "1 + 2"]
# add two numbers without the quotes
set result [SclExpr 1 + 2]
# take the cosine of 45 degrees
set result [SclExpr "cosd(45)"]
# get the length of a text string
set result [SclExpr "strlen('a text string')"]
# add two numbers stored in variables
set a 1
set b 2
set result [SclExpr "$a + $b"]