# Will this work? Is it more efficient?

R

I wanted to be able to write without a keyboard, so i made one. It is for name input in games, i have designed it to be easy to put into almost any program as a sub.

However, i use a lot of IF statements. They nearly all are for mouse co-ordinates, all off wich are exact distances apart.

I was wondering if it were possible to do a DO LOOP to achieve the same sort of output.

i think it would be a bit like this....written here not in qb..the values are not set properly, i doubt it works as is, it is for the first 10 squares, 0-9

cnt% =0: tlstart% = 80:tlend% = 110 (screen coordiantes for first tile sides)

IF MB = 1 and my > 120 AND my < 152 THEN
DO
if mx> tlstart% and my < tlend% THEN usr\$ = usr\$ + STR\$(cnt%):exit do
cnt% = cnt% + 1:tlstart% = tlstart% + 40:tlend% = tlstart% + 30
LOOP INTIL CNT% = 10
END IF

I would do the same again for the letters and other buttons.though they may need to be a bit more complex

My Code for the program is as follows, feel free to use it if you want....UNSEEN

'GAME STYLE NAME ENTRY - MADE TO BE ADDED TO OTHER CODE AS A SUB
'I WILL REPLACE ALL THE IFS WITH A DO LOOP AND A COUPLE OF IFS- if possible
'BUT FOR NOW IT WORKS..

DECLARE SUB kbrd ()
DIM USR AS STRING
SCREEN 12
CLS
CALL kbrd
CLS
SLEEP 1
LOCATE 15, 40 - (LEN(USR\$) \ 2): PRINT USR\$

SUB kbrd
SHARED USR AS STRING
DIM tlx AS INTEGER, tly AS INTEGER, tlcnt AS INTEGER, num AS INTEGER
DIM itmcnt AS INTEGER, itmx AS INTEGER, itmy AS INTEGER, capval AS INTEGER
COLOR 1
'MOUSE
DIM m(8) AS LONG, mb AS INTEGER, MX AS INTEGER, my AS INTEGER
m(0) = &H8BE58955
m(1) = &H78B0C5E
m(2) = &HD88933CD
m(3) = &H890A5E8B
m(4) = &H85E8B07
m(5) = &H5E8B0F89
m(6) = &H5D178906
m(7) = &H8CA
DEF SEG = VARSEG(m(0))
CALL absolute(1, mb, MX, my, VARPTR(m(0)))
CALL absolute(3, mb, MX, my, VARPTR(m(0)))

'INITIAL VALUES
tlx = 200: tly = 84: itmcnt = 0: itmx = 12: itmy = 10: num = 0

'TILES
LTRTLE\$ = "L12 H3 U24 E3 R24 F3 D24 G3 L12"
SPC\$ = "l180 h3 u24 e3 r360 f3 d24 g3 l180"
CapDne\$ = "l30 h3 u24 e3 r60 f3 d24 g3 l30"
Dle\$ = "l40 h3 u24 e3 r80 f3 d24 g3 l40"
nmtle\$ = "l150 h3 u24 e3 r300 f3 d24 g3 l150"

DO
PSET (tly, tlx): DRAW LTRTLE\$
tly = tly + 40
tlcnt = tlcnt + 1
IF tlcnt = 10 THEN tlx = tlx + 45: tly = 84
IF tlcnt = 23 THEN tlx = tlx + 48: tly = 84
LOOP UNTIL tlcnt = 36
PSET (320, 342): DRAW SPC\$
PSET (530, 200): DRAW Dle\$
PSET (100, 342): DRAW CapDne\$
PSET (540, 342): DRAW CapDne\$
PSET (320, 150): DRAW nmtle\$

COLOR 1
DO
IF itmcnt < 10 THEN
LOCATE itmx, itmy: PRINT itmcnt: itmy = itmy + 5
END IF
IF itmy > 55 AND itmcnt <= 9 THEN itmy = 11: itmx = itmx + 3
IF itmcnt >= 10 THEN
LOCATE itmx, itmy: PRINT CHR\$(itmcnt + 55): itmy = itmy + 5
IF itmy > 75 AND itmcnt < 30 THEN itmy = 11: itmx = itmx + 3
END IF
itmcnt = itmcnt + 1
LOOP UNTIL itmcnt = 36
LOCATE 12, 63: PRINT "Backspace"
LOCATE 21, 38: PRINT "SPACE"
LOCATE 21, 11: PRINT "CAPS"
LOCATE 21, 66: PRINT "ENTER"

DO

DO
CALL absolute(3, mb, MX, my, VARPTR(m(0)))
LOOP UNTIL mb = 1

'space - enter - caps line
IF mb = 1 AND my > 311 AND my < 343 THEN
IF MX > 506 AND MX < 572 THEN EXIT DO
IF MX > 137 AND MX < 503 THEN USR\$ = USR\$ + " "
IF MX > 66 AND MX < 132 THEN capval = 1 'NOT YET CODED
END IF

'numbers & BACKSPACE
IF mb = 1 AND my > 169 AND my < 200 THEN
IF MX > 486 AND MX < 572 THEN USR\$ = LEFT\$(USR\$, LEN(USR\$) - 1)
IF MX > 69 AND MX < 99 THEN USR\$ = USR\$ + "0"
IF MX > 109 AND MX < 139 THEN USR\$ = USR\$ + "1"
IF MX > 149 AND MX < 179 THEN USR\$ = USR\$ + "2"
IF MX > 188 AND MX < 219 THEN USR\$ = USR\$ + "3"
IF MX > 229 AND MX < 259 THEN USR\$ = USR\$ + "4"
IF MX > 269 AND MX < 299 THEN USR\$ = USR\$ + "5"
IF MX > 309 AND MX < 339 THEN USR\$ = USR\$ + "6"
IF MX > 349 AND MX < 379 THEN USR\$ = USR\$ + "7"
IF MX > 389 AND MX < 419 THEN USR\$ = USR\$ + "8"
IF MX > 429 AND MX < 459 THEN USR\$ = USR\$ + "9"
END IF

'letters - FIRST LINE A TO M
IF mb = 1 AND my > 215 AND my < 245 THEN
IF MX > 69 AND MX < 99 THEN USR\$ = USR\$ + "A"
IF MX > 109 AND MX < 139 THEN USR\$ = USR\$ + "B"
IF MX > 149 AND MX < 179 THEN USR\$ = USR\$ + "C"
IF MX > 188 AND MX < 219 THEN USR\$ = USR\$ + "D"
IF MX > 229 AND MX < 259 THEN USR\$ = USR\$ + "E"
IF MX > 269 AND MX < 299 THEN USR\$ = USR\$ + "F"
IF MX > 309 AND MX < 339 THEN USR\$ = USR\$ + "G"
IF MX > 349 AND MX < 379 THEN USR\$ = USR\$ + "H"
IF MX > 389 AND MX < 419 THEN USR\$ = USR\$ + "I"
IF MX > 429 AND MX < 459 THEN USR\$ = USR\$ + "J"
IF MX > 469 AND MX < 499 THEN USR\$ = USR\$ + "K"
IF MX > 509 AND MX < 539 THEN USR\$ = USR\$ + "L"
IF MX > 549 AND MX < 579 THEN USR\$ = USR\$ + "M"
END IF

'letters - SECOND LINE N TO Z
IF mb = 1 AND my > 262 AND my < 292 THEN
IF MX > 69 AND MX < 99 THEN USR\$ = USR\$ + "N"
IF MX > 109 AND MX < 139 THEN USR\$ = USR\$ + "O"
IF MX > 149 AND MX < 179 THEN USR\$ = USR\$ + "P"
IF MX > 188 AND MX < 219 THEN USR\$ = USR\$ + "Q"
IF MX > 229 AND MX < 259 THEN USR\$ = USR\$ + "R"
IF MX > 269 AND MX < 299 THEN USR\$ = USR\$ + "S"
IF MX > 309 AND MX < 339 THEN USR\$ = USR\$ + "T"
IF MX > 349 AND MX < 379 THEN USR\$ = USR\$ + "U"
IF MX > 389 AND MX < 419 THEN USR\$ = USR\$ + "V"
IF MX > 429 AND MX < 459 THEN USR\$ = USR\$ + "W"
IF MX > 469 AND MX < 499 THEN USR\$ = USR\$ + "X"
IF MX > 509 AND MX < 539 THEN USR\$ = USR\$ + "Y"
IF MX > 549 AND MX < 579 THEN USR\$ = USR\$ + "Z"
END IF

LOCATE 9, 41 - (LEN(USR\$) / 2): PRINT SPACE\$(LEN(USR\$) + 1)
LOCATE 9, 41 - (LEN(USR\$) / 2): PRINT USR\$

'reset mouse
DO
CALL absolute(3, mb, MX, my, VARPTR(m(0)))
LOOP UNTIL mb = 0

LOOP UNTIL LEN(USR\$) = 12

END SUB

Posted on Jan 4, 2010, 6:46 PM

 Response Title Author and Date I don't like math that much, but I like typing a lot less... Pete on Jan 4 Thanks, i did it!!!! unseenmachine on Jan 5 Next stop: implement Dasher in QB Artelius on Jan 8 * That does it! Who gave the A-Man a hot-glue bong? Pete on Jan 8