Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | misc | |
Tool | misc |
thing | Variable to convert | ||
Allowed: | Any Glish variable | ||
type | Specify the output type of the vector | ||
Allowed: | String chosen from `string', `float', `double', `integer' | ||
Default: | 'string' | ||
unsetvalue | Unset value for unset items in records | ||
Allowed: | Numeric value | ||
Default: | unset |
Its purpose is so that a vector variable can be specified as a vector, a string, or a vector of strings. Thus no matter how the vector is entered to Glish, the right thing comes back. It is really meant for numeric and string vectors. If you put in what you want out (e.g. input a float vector and ask for the output to be a float vector) that is ok. If the input is a string, you can use space or comma or both delimiters.
After attempting to convert the input (argument thing) to a vector, it is type converted to the specified type.
The unsetvalue argument is only relevant if the input thing is a record. Then, any fields in the record that are unset, are replaced by unsetvalue. If unsetvalue=unset and a record field is unset, then an exception will be thrown. The record fields are then converted to vector of the appropriate type.
- dms.tovector("1 2.2 3", 'double') # Vector of strings [1 2.2 3] - dms.tovector('1 2.2 3', 'double') # String (space delimiters) [1 2.2 3] - dms.tovector('1, 2.2, 3', 'double') # String (space and comma delimiters) [1 2.2 3] - dms.tovector([1,2.2,3], 'float') # Numeric vector [1 2.2 3] - dms.tovector([1,2.2,3], 'integer') # Float -> integer - r := [=] - r.a := '1' - r.b := unset # Unset field - r.c := 2 - dms.tovector(r,'float', 20) # Record -> float [1 20 2]