NAME

str2var - convert a string to a value

SYNOPSIS

oadl::str2var(str)

DESCRIPTION

The str2var() function converts the string str into an OADL value. It first attempts to parse the string as a numeric constant (Integer, Float, etc.). If parsing fails, it attempts to look up the string as a defined name (variable, constant, or procedure) in the current context.

RETURN VALUE

The value represented by the string str.

ERRORS

ArgCheck if exactly one argument is not provided.
TypeCheck if str is not a string.
UndefName if the string cannot be parsed as a number and does not match any defined name.

EXAMPLE

    v = oadl::str2var("3.14159")
    typeof(v)
Float

    v = oadl::str2var("nil")
    typeof(v)
Null

SEE ALSO

getvar
typeof