The monadic system function ŒVI is used in conjunction with ŒFI to
validate a text string and convert it to numeric form. In both cases, the argument is a character
vector (or scalar), containing one or more sub-strings of characters separated
by blanks. For each non-blank
sub-string, ŒVI returns a 1 if the sub-string
represents a valid number, and 0 if it does not. ŒFI returns the numeric representation of the sub-string, or 0 if it
is not a valid number. Numbers are validated and converted in the same way as normal APL input. Scientific notation is supported, and negative numbers are prefixed by the high minus (¯) character. For example:
ŒFI '100.32 $4 2,,3 0 12.2 ¯3 +2 -2' 100.32 0 0 0 12.2 ¯3 0 0 ŒVI '100.32 $4 2,,3 0 12.2 ¯3 +2 -2' 1 0 0 1 1 1 0 0
ŒVI
and ŒFI are usually used to validate
and convert user input, or to convert text files to numeric form. To allow users to enter negative numbers
using the ordinary (non-APL) minus sign, you can use ŒSS to translate minus to high-minus first. To allow comma-delimited input, use ŒSS to translate comma to space:
STRING„'3,-2,45.5,-0.08' ŒVI STRING 0 ŒSS (STRING; ('-';','); ('¯';' ')) 3 ¯2 45.5 ¯0.08 ŒVI ŒSS (STRING; ('-';','); ('¯';' ')) 1 1 1 1 ŒFI ŒSS (STRING; ('-';','); ('¯';' ')) 3 ¯2 45.5 ¯0.08