\012345678901234567890123456789012345 \ User input/Graphical.......... X . \ Please enter a string and 75000: . \ String: Hello, World!___. . \ Number: 75000___________. . def X0=20, Y0=10; \position of upper-left corner of window (chars) int Mouse, Button, X, Y, Ch, I, SN; \SN = string number = 0 or 1 def StrMax = 16; \maximum number of characters in strings char String(2, StrMax); \2 string arrays (including Number string) int StrInx(2); \index to character to be added to String func GetButton; \Return soft button number at mouse pointer [Mouse:= GetMouse; X:= Mouse(0)/8 - X0; \convert pixels to 8x16-pixel character cells Y:= Mouse(1)/16 - Y0; if X>=32 & X<=34 & Y=0 then return 0; \exit [X] if X>=10 & X<=10+StrMax & Y=4 then return 1; \line 1 if X>=10 & X<=10+StrMax & Y=6 then return 2; \line 2 return -1; \mouse not on any soft button ]; proc ShowCursor(Flag); \Turn cursor at end of active String on or off int Flag; [Cursor(10+StrInx(SN)+X0, 4+SN*2+Y0); ChOut(6, if Flag then ^_ else ^ ); ]; [SetVid($12); \set 640x480 graphics TrapC(true); \prevent Ctrl+C from aborting the program Attrib($70); \set black-on-gray color attribute SetWind(0+X0, 0+Y0, 35+X0, 8+Y0, 0, \fill\true); \draw gray rectangle Cursor(33+X0, 0+Y0); Text(6, "X"); \draw exit button Cursor(2+X0, 2+Y0); Text(6, "Please enter a string and 75000:"); Cursor(2+X0, 4+Y0); Text(6, "String:"); Cursor(2+X0, 6+Y0); Text(6, "Number:"); Attrib($9F); \set bright white on light blue, for title bar Cursor(0+X0, 0+Y0); Text(6, " User input/Graphical "); Attrib($F0); \set black on bright white for SN:= 0 to 1 do \initialize Strings [Cursor(10+X0, 4+SN*2+Y0); for I:= 0 to StrMax-1 do [String(SN, I):= ^ ; ChOut(6, ^ )]; ChOut(6, ^ ); \add one more for cursor underline at StrMax StrInx(SN):= 0; ]; SN:= 0; \select first (topmost) String ShowCursor(true); ShowMouse(true); \turn on mouse pointer loop [MoveMouse; \make pointer track mouse movements Mouse:= GetMouse; \get pointer to mouse array information if Mouse(2) then \a left or right mouse button is down [Button:= GetButton; \get soft button at mouse pointer while Mouse(2) do \wait for mouse button(s) to be released [MoveMouse; Mouse:= GetMouse; ]; if Button = GetButton then \if down Button = release button and it [if Button = 0 then quit; \is the exit [X] button then quit loop if Button # -1 then \move cursor underline to active String [ShowMouse(false); \don't overwrite mouse pointer ShowCursor(false); \turn off cursor at old String position SN:= Button-1; ShowCursor(true); \turn on cursor for selected String ShowMouse(true); \mouse pointer is normally displayed ]; ]; ]; if KeyHit then [ShowMouse(false); \don't overwrite mouse pointer ShowCursor(false); \remove cursor underline cuz it moves Ch:= ChIn(1); \get character from non-echoed keyboard if SN=0 & Ch>=$20 & Ch<=$7E or \allow all printable chars SN=1 & Ch>=$30 & Ch<=$39 then \allow only numeric digits [if StrInx(SN) < StrMax then [String(SN, StrInx(SN)):= Ch; StrInx(SN):= StrInx(SN)+1]; ] else if Ch = \BS\$08 then \delete back a character [if StrInx(SN) > 0 then StrInx(SN):= StrInx(SN)-1] else if Ch = \tab\$09 then \select next string SN:= rem((SN+1)/2) else if Ch = \Esc\$1B then quit; Cursor(10+X0, 4+SN*2+Y0); \show active String for I:= 0 to StrInx(SN)-1 do ChOut(6, String(SN, I)); ChOut(6, ^_); \show cursor underline at end of String ShowMouse(true); ]; ]; \loop SetVid(3); \restore normal text mode immediately ]