Here is an updated, and more elegant, numeric filter solution. Thanks
to the more recent suggestions, this one reacts better to "." and "-"
when typing with selected text. This was an EXCELLENT learning
experience. Thanks a ton to all who contributed. This little snippet
is going in the SAVE FOR FREQUENT USE bin.
[extra spaces added here for easier reading]
LOCAL FN numericFilter
DIM AS STR15 k
DIM AS STR255 cStr
DIM AS LONG id, p, n
DIM AS BOOLEAN pass
k = TEKEY$
id = WINDOW(_efNum)
cStr = EDIT$(id)
n = INSTR(1, cStr, "-")
pass = _True
SELECT ASC(k)
CASE 8, 28, 29, 30, 31, 127
CASE > ASC("9") : pass = _False
CASE >= ASC("0")
CASE ASC(".")
IF WINDOW( _selEnd ) < n THEN pass = _False
p = INSTR(1, cStr, ".")
LONG IF p
IF WINDOW( _selEnd ) <= p THEN pass = _False
IF WINDOW(_selStart) >= p THEN pass = _False
END IF
CASE ASC("-")
IF WINDOW(_selStart) THEN pass = _False
IF window( _selEnd ) < n THEN pass = _False
CASE ELSE : pass = _False
END SELECT
IF pass THEN TEKEY$ = k
END FN
--
-- Chip <mailto:n1mie@...>