|
Post by b03a8b on Aug 19, 2018 15:12:54 GMT -5
I am writing a program to let runners enter their bib # and have their place, time etc returned. The bib # keeps "walking down the page" with each successive entry. I think I am telling it to place the number in the same place every time. The text "Bib" is printed in the desired location every time but the variable bibadr$ is displayed about one letter height lower every time. What am I doing wrong?
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
DW = DisplayWidth
DH = DisplayHeight
UpperLeftX = 1
UpperLeftY = 1
open "Results Kiosk" for graphics_fs_nsb as #1
print #1, "when characterInput [keyPressed]"
print #1, "trapclose [quit]"
print #1, "font Arial 20 bold"
print #1, "place 550 25"
print #1, "\Today is ";date$("mm/dd/yyyy")
print #1, "place 50 625"
print #1, "\Press 'ENTER' to start "
' Wait for a key to be pressed
[loopHere]
' make sure #1 has input focus
print #1, "setfocus"
' scan for events
scan
t = time$("ms")
goto [loopHere]
[keyPressed]
key$ = Inkey$
if asc(key$) = 13 then qctr = qctr + 1
' After start, go to wait loop
if asc(key$) = 13 then if qctr = 1 then goto [loopHere]
' Accumulate bib numbers
if asc(key$) <> 13 then bibadr$ = bibadr$ + key$ : gosub [graphprint]
'gosub [TimeFormat]
goto [loopHere]
[graphprint]
print #1, "place "; .76 * DW; " " ; .12 * DH
print #1, "font Arial 40 bold"
print #1, "\Bib "
print #1, "place "; .76 * DW; " " ; .20 * DH
print #1, "\" ; bibadr$
print #1, "font Arial 20 bold"
return
|
|
|
Post by tsh73 on Aug 20, 2018 16:01:55 GMT -5
Basically, your bibadr$ kept accumulating previous entries with line break So then you printed it printed over several lines.
But there is an interface question - user should know somehow that he is in input mode I tried something along these lines (then pressing ENTER reset bibadr$ to ""; show something like a caret; overtype old value with spaces; and change a color with each ENTER to show something is going on) You can mix / match / discard this for your liking.
WindowWidth = DisplayWidth WindowHeight = DisplayHeight DW = DisplayWidth DH = DisplayHeight UpperLeftX = 1 UpperLeftY = 1
open "Results Kiosk" for graphics_fs_nsb as #1 print #1, "when characterInput [keyPressed]" print #1, "trapclose [quit]" print #1, "font Arial 20 bold" print #1, "place 550 25" print #1, "\Today is ";date$("mm/dd/yyyy") print #1, "place 50 625" print #1, "\Press 'ENTER' to start "
' Wait for a key to be pressed [loopHere]
' make sure #1 has input focus print #1, "setfocus"
' scan for events scan t = time$("ms") goto [loopHere]
[keyPressed] key$ = Inkey$ if len(Inkey$)>1 then wait 'These aren't the Droids you're looking for 'if asc(key$)<32 then print "asc(key$)";asc(key$) 'debug print if asc(key$) = 13 then qctr = 1 ' After start, go to wait loop if qctr<>1 then wait if asc(key$) = 13 and qctr = 1 then colr=1-colr print ">";bibadr$;"<" 'you can do something with it here, before clearing bibadr$ = "" gosub [graphprint] goto [loopHere] end if ' Accumulate bib numbers if asc(key$) <> 13 then bibadr$ = bibadr$ + key$ : gosub [graphprint] 'gosub [TimeFormat]
goto [loopHere]
[graphprint] print #1, "color ";word$("red blue", colr+1) print #1, "place "; .76 * DW; " " ; .12 * DH print #1, "font Arial 40 bold" print #1, "\Bib " print #1, "place "; .76 * DW; " " ; .20 * DH print #1, "\" ; bibadr$;"|";space$(20) 'like a caret, and clear old text
print #1, "font Arial 20 bold" 'print ">";bibadr$;"<" 'debug print return
[quit] timer 0 close #1 end
|
|