Fast Data Entry

A Demo by Bill Jennings


NewsLetter TOC

Newsletter Home

Blast

MDI

OS Editor

LBW Review

Fast Data

SQLite

Tsunami

Begin Prog II

Locate/LBCard

FastDataEntry.bas is a demo program for rapid data entry! The features of this cool little program include the following:

See FastDataEntry.bas below. Copy and paste it into the LB Editor!


'   fastDataEntry.bas  --  No-mouse entries with the number pad.
'   Use graphicbox instead of textboxes or listboxes.

    gosub [getPrompts]
    mx=999  '*** maximum input (make it whatever).
    inpX=200 : inpY=82  '*** location of input box.
    inpW=80 : inpH=16  '*** width & height of input box.

    nomainwin
    WindowWidth=300 : WindowHeight=520
    graphicbox #w1.g1a,0,0,0,0  '*** box for inputs
    graphicbox #w1.g1,10,94,274,400
    button #w1.b1,"Press X to exit",[quit],UL,40,4
    statictext #w1.st1,"Press Escape key to back up",30,68,200,24
    open "Fast (Mouseless) Data Entry" for window as #w1

    gosub [getInputs]

  [quit]
    notice "Inputs complete"
    close #w1 : END

[getInputs]  '*** show prompts and get inputs
    maxShow=24  '*** max lines to fill graphicbox
    yStart=20  '*** beginning y-position to show top prompt
    yIncr=16  '*** increment line to line
    j=1
  [loopJ]
    grp=int((j-1)/(maxShow))
    if j=1 or grp=(j-1)/maxShow then
      if not(backup) then gosub [showGroup]
    end if

    gosub [scanIndex]

    if quit then [quit]  '*** abort loop
    if backup then
      j=j-1 : if j<1 then j=1
      if j=st-1 then
        if st>1 then
          gosub [showPriorGroup]
        end if
      else
          '*** retract input box.
        yPos=(j-grp*maxShow-1)*yIncr+yStart
        print #w1.g1a,"locate ";inpX;" ";inpY+yPos;" ";inpW;" ";inpH
        print #w1,"refresh"

         '*** display entry where box was.
        yPos=(j-grp*maxShow)*yIncr+yStart
        print #w1.g1,"place 230 ";yPos
        print #w1.g1,"\";r$(j+1)
      end if
    else
       '*** advance input box
       '*** Only if an entry was made, update the input box:
      if ntry$>"" then r$(j)=ntry$
      yPos=(j-grp*maxShow)*yIncr+yStart
      print #w1.g1a,"locate ";inpX;" ";inpY+yPos;" ";inpW;" ";inpH
      print #w1,"refresh"

        '*** display entry where box was.
      yPos=(j-grp*maxShow-1)*yIncr+yStart
      print #w1.g1,"place 230 ";yPos
      print #w1.g1,"\";r$(j)
      j=j+1
    end if
    if jkQ then en=kQ

     '*** show prompts & top input box
    print #w1.g1,"cls"
    for h=st to en
      yPos=(h-grp*maxShow-1)*yIncr+yStart
      print #w1.g1,"place 4 ";yPos
      print #w1.g1,"\";q$(h)
      print #w1.g1,"place 230 ";yPos
      print #w1.g1,"\";r$(h)
    next h
    yPos=(j-grp*maxShow-1)*yIncr+yStart
    print #w1.g1a,"locate ";inpX;" ";inpY+yPos;" ";inpW;" ";inpH
    print #w1,"refresh"
  RETURN

[scanIndex]  '*** get index number
    ntry$=""
    R=255 : G=255 : B=165  '*** pale yellow
    print #w1.g1a, "cls"
    print #w1.g1a, "fill ";R;" ";G;" ";B

    print #w1.g1, "when characterInput [keyDown]"
    print #w1.g1, "setfocus"

[scanNum]
      calldll #kernel32,"Sleep",1 as ulong, res as void
    SCAN
  goto [scanNum]

  [keyDown]
    key$=Inkey$ : backup=0 : enter=0
    if len(key$)<2 then
      ndx=asc(key$)
    else
      ndx=asc(mid$(key$,2,1))
    end if

    if ndx=120 or ndx=88 then quit=1 : RETURN  '*** X key to [quit]

  'This seems redundant, but it's necessary
     'for Enter, Escape and Backspace keys (maybe others)!!!
    if ndx=13 and asc(key$)=13 then enter=1 : RETURN
    if ndx=27 and asc(key$)=27 then backup=1 : RETURN
    if ndx=8 and asc(key$)=8 then  '*** Backspace key
      ntry$=left$(ntry$,len(ntry$)-1)
      gosub [printNum]
    end if

     '*** accept a number, decimal, slash or space:
    if ndx>44 and ndx<58 or ndx=32 then
      ntry$=ntry$+chr$(ndx)
      gosub [printNum]
    end if

    if val(ntry$)>mx then
      NOTICE ntry$+" exceeds the maximum ";mx
      ntry$=left$(ntry$,len(ntry$)-1)
      gosub [printNum] : RETURN
    end if
  goto [scanNum]

[printNum]
    print #w1.g1a, "cls;fill ";R;" ";G;" ";B
    print #w1.g1a, "backcolor ";R;" ";G;" ";B
    print #w1.g1a, "place 8 12;\"+ntry$
  RETURN

[getPrompts]
    kQ=74 : DIM q$(kQ) : DIM r$(kQ)
    for j=1 to kQ
      q$(j)="Prompt #"+str$(j)
      r$(j)=str$(j)  '*** responses
    next j
  RETURN

NewsLetter TOC

Newsletter Home

Blast

MDI

OS Editor

LBW Review

Fast Data

SQLite

Tsunami

Begin Prog II

Locate/LBCard