Home   Archive   Permalink



Heads-down data entry

I am thinking of experimenting with another kind of application that REBOL might not have been designed for, the idea of 'heads-down' data entry where a person keys data into a screen, from a piece of paper, probably using the numeric keypad, without ever using the mouse or looking at the keyboard. All/most fields will contains fixed numbers of characters (like a date containing eight), and when a field on the screen is filled with the expected number of characters the focus automatically jumps to the next field. As an added bonus, when that last character of a field is typed, the program could perform some validation. For example, after the eighth digit of a date is entered, the program could check the date for validity, beep the computer if invalid, or move the focus to the next field if valid.    
    
I am wondering if anyone can point me in a general direction for investigation. The best idea I can think of so far is to set the inter-field spacing to zero, and then make a 20-pixel field for each individual character, and then capture keystrokes the way it is done on the various calculator programs one can find on rebol.org.
    
Thank you.

posted by:   Steven White       16-Feb-2017/11:16:10-8:00



R E B O L []
beep-sound: load to-binary decompress 64#{
eJwBUQKu/VJJRkZJAgAAV0FWRWZtdCAQAAAAAQABABErAAARKwAAAQAIAGRhdGEl
AgAA0d3f1cGadFQ+T2Z9jn1lSjM8T2uNsM/j7Midc05PWGh4eXVrXE5DQEZumsTn
4M2yk3hiVU9fcX+GcFU8KkNmj7rR3+HYroJbPUpfdoqAbldBP0ZWbpW62OvRrohk
WlleaHB2dW9bRzo1WYWy3OHbyrKObVNCVGp/jXpgRC48Vnievtfm6MCUaUVLWW1/
fXNkUkdCRlN7ps3r3cSkgm1fWFhmdH2AaVA6LElwnMja4dzNpHtXPUxje45/aVA5
PUtif6TG3uvMpHtXU1lkcnd2cGVURT0+ZJC84+HUvaGCZ1NIWm6AinVaQCtAX4Wu
yt3k37aJYEBKXXOHf3FdSEJET2KJsdPr1reUcGJbW2FsdXl2YUs5MFF7qdPe3tO+
mHNUP1Bnfo59ZEkyPFFukbTR5OvGm3BMTVlpent1aVpMQ0FJcZ3I6uHMsJB2YlZR
YXJ/hW5UOypEaJK90+Dg1qyBWjxKYHeLgG1WPz9HWXKYvNnr0KyFYVhZX2pydnVu
Wkc7N1yHtN3h2sivjGxTRFZrgI15X0MtPVh7osHZ5ua+kmdES1tvgn5zY1BGQ0hW
fqjO69vBoX9rXllaaHV9fmhPOi1Lcp/K2+DayaF4Vj1NY3uNfmhONjxLZIKnyODr
yqJ4VFFYZHN3dm5iUUM9QGaTv+Th0rqdf2VTSltvgIl0WT4rQGCIssze5N60iF8/
Sl10h39vW0ZBRFFljLPU69W1kG1gWlxiYHkWb1ECAAA=
}
beep: does [sp: open sound:// insert sp beep-sound wait sp close sp]
digits: charset "0123456789"
f1incomplete: yes
w: view/new layout [
    f1: field
    f2: field
]
forever [
    if all [f1incomplete 8 = length? ft: f1/text][
     either parse ft [8 digits][
        f1incomplete: no
        focus f2
     ][
        beep
     ]
    ]
    show w if not viewed? w [quit] wait .2    
]

posted by:   Nick       16-Feb-2017/22:30:15-8:00



It's much simpler if you can require the user to press ENTER at the end if each field:
    
R E B O L []
beep-sound: load to-binary decompress 64#{
eJwBUQKu/VJJRkZJAgAAV0FWRWZtdCAQAAAAAQABABErAAARKwAAAQAIAGRhdGEl
AgAA0d3f1cGadFQ+T2Z9jn1lSjM8T2uNsM/j7Midc05PWGh4eXVrXE5DQEZumsTn
4M2yk3hiVU9fcX+GcFU8KkNmj7rR3+HYroJbPUpfdoqAbldBP0ZWbpW62OvRrohk
WlleaHB2dW9bRzo1WYWy3OHbyrKObVNCVGp/jXpgRC48Vnievtfm6MCUaUVLWW1/
fXNkUkdCRlN7ps3r3cSkgm1fWFhmdH2AaVA6LElwnMja4dzNpHtXPUxje45/aVA5
PUtif6TG3uvMpHtXU1lkcnd2cGVURT0+ZJC84+HUvaGCZ1NIWm6AinVaQCtAX4Wu
yt3k37aJYEBKXXOHf3FdSEJET2KJsdPr1reUcGJbW2FsdXl2YUs5MFF7qdPe3tO+
mHNUP1Bnfo59ZEkyPFFukbTR5OvGm3BMTVlpent1aVpMQ0FJcZ3I6uHMsJB2YlZR
YXJ/hW5UOypEaJK90+Dg1qyBWjxKYHeLgG1WPz9HWXKYvNnr0KyFYVhZX2pydnVu
Wkc7N1yHtN3h2sivjGxTRFZrgI15X0MtPVh7osHZ5ua+kmdES1tvgn5zY1BGQ0hW
fqjO69vBoX9rXllaaHV9fmhPOi1Lcp/K2+DayaF4Vj1NY3uNfmhONjxLZIKnyODr
yqJ4VFFYZHN3dm5iUUM9QGaTv+Th0rqdf2VTSltvgIl0WT4rQGCIssze5N60iF8/
Sl10h39vW0ZBRFFljLPU69W1kG1gWlxiYHkWb1ECAAA=
}
beep: does [sp: open sound:// insert sp beep-sound wait sp close sp]
digits: charset "0123456789"
view layout [
    f1: field [either parse face/text [8 digits][focus f2][beep]]
    f2: field
]

posted by:   Nick       16-Feb-2017/22:41:04-8:00



If you want to distribute a separate wav file:
    
R E B O L []
digits: charset "0123456789"
view layout [
    f1: field [
     either parse face/text [8 digits][focus f2][
        insert s: open sound:// load %/c/windows/media/chord.wav wait s close s
     ]
    ]
    f2: field
]

posted by:   Nick       16-Feb-2017/22:52:28-8:00



Put the validation routine into a function, and it's easy to add fields with any validation rules you want:
    
R E B O L []
call ""
digits: charset "0123456789"
validate: func [f rule] [
    if not parse f/text rule [attempt [
     insert s: open sound:// load %/c/windows/media/chord.wav wait s close s
    ]]
]
view layout [
    f1: field [validate face [8 digits]]
    field [validate face [4 digits]]
    field [validate face ["(" 3 digits ")"]]
    do [focus f1]
]

posted by:   Nick       17-Feb-2017/11:12:07-8:00



I added this one to the short examples page:
    
R E B O L [title: "Field Validator"]
nums: charset "0123456789" alfs: charset [#"a" - #"z" #"A" - #"Z"] call ""
validate: func [f rule] [if not parse f/text rule [attempt [
    insert s: open sound:// load %/c/windows/media/chord.wav wait s close s
]]]
view layout [
    f1: field "12345678" [validate face [8 nums]]
    field "1234" [validate face [4 nums]]
    field "(555)123-2345" [validate face ["(" 3 nums ")" 3 nums "-" 4 nums]]
    field "me@url.com" [validate face [some alfs "@" some alfs "." 3 alfs]]
    do [focus f1]
]

posted by:   Nick       18-Feb-2017/5:59:36-8:00