# Glimmr Form Fields

## version 1/101201 by Erik Temple

Section - Fields that accept only numbers

An input interpretation rule for a numerical g-element (called the field) (this is the field to number conversion rule):
if the field is not form input:
#if utilizing Glimmr debugging;
say "[>console][FFs]***Warning: The g-element [i][field][/i] has been given the 'numerical' property, but only elements that also have the 'form input' property can be be acted on.[<]";
#end if;
continue the action;
let val be the text-string of the input-stream of the field as a number;
now the associated value of the field is val.

To decide which number is (S - indexed text) as a number:
let is-negative be false;
replace the regular expression "\s" in S with "";
replace the regular expression "^\+" in S with "";
if character number 1 in S is "-":
let is-negative be true;
replace the regular expression "\-" in S with "";
if S matches the regular expression "<^0-9>", decide on 0;
let len be the number of characters in S;
if len is 0, decide on 0;
let result be 0;
repeat with N running from 0 to (len - 1):
let digit be character number (len - N) in S;
let multiplier be 10 to the power N;
if digit is "0":
next;
if digit is "1":
let result be multiplier + result;
next;
if digit is "2":
let result be (multiplier * 2) + result;
next;
if digit is "3":
let result be (multiplier * 3) + result;
next;
if digit is "4":
let result be (multiplier * 4) + result;
next;
if digit is "5":
let result be (multiplier * 5) + result;
next;
if digit is "6":
let result be (multiplier * 6) + result;
next;
if digit is "7":
let result be (multiplier * 7) + result;
next;
if digit is "8":
let result be (multiplier * 8) + result;
next;
if digit is "9":
let result be (multiplier * 9) + result;
next;
decide on 0;
if is-negative is true, let result be 0 - result;
#if utilizing Glimmr debugging;
say "[>console][FFs]The input received in numerical field element [i][current field][/i] was interpreted as the number [result].[<]";
#end if;
decide on result;