Updated May 2021
The .VALX(a$) function is an extended version of the traditional VAL(). It supports all of the same behavior, plus it automatically skips over any amount of non-numeric text preceding the number, and also recognizes common types of numeric formatting such as thousands separators, currency symbols, and parentheses for negatives. This makes it particularly handy for importing values from spreadsheets and reading numeric cells in XTREE.
Examples
Expression |
val(expr) |
.valx(expr) |
Notes |
123 |
123 |
123 |
|
123 |
123 |
123 |
leading spaces |
-123 US |
-123 |
-123 |
leading minus and spaces |
$123 |
0 |
123 |
leading non-digits |
-$123.45 |
0 |
-123.45 |
leading -$ |
123,456.78 |
123 |
123456.78 |
thousands separators |
($1,234.56) |
0 |
-1234.56 |
parentheses for neg |
price: (USD) 0.99 |
0 |
0.99 |
(USD) ignored (non-numeric) |
&h0200 |
512 |
512 |
&h for hex |
&O0200 |
128 |
128 |
&o for octal |
hex flags: &h0200 |
0 |
512 |
leading text |
hex flags: 0x0200 |
0 |
512 |
0x for hex |
octal flags: o0200 |
0 |
128 |
0o for octal |
binary flags: 0b10110 |
0 |
22 |
0b for binary |
&b1010101010101010 |
0 |
43690 |
&b for binary |
History
2021 April, A-Shell 6.5.1702: Add function to A-Shell.