
-----------------------------------
mapleleafs1917
Thu May 22, 2014 8:40 pm

Waiting for user input in Turing Game
-----------------------------------
What is it you are trying to achieve?
I want the program to wait until the user has entered their text into the textbox and then continue from there


What is the problem you are having?
I cannot seem to figure out how to do that.


Describe what you have tried to solve this problem
I have used getch and i tried using delay but nothing is working.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




import GUI
View.Set ("graphics: 1280;994, nobuttonbar")
GUI.SetBackgroundColor (77)

var font : int
var font2 : int
var player1Name, player2Name : int
var aButton, bButton, cButton, dButton, eButton, fButton, gButton, hButton, iButton, jButton, kButton, lButton, mButton, nButton, oButton, pButton, qButton, rButton, sButton, tButton, uButton,
    vButton, wButton, xButton, yButton, zButton : int
var quitter : int
var continue : int
var anykey :string


proc enter
put ""
end enter

procedure nameEntered (text : string)
    GUI.SetSelection (player2Name, 0, 0)
    GUI.SetActive (player2Name)
end nameEntered

procedure name2Entered (text : string)
    GUI.SetSelection (player1Name, 0, 0)
    GUI.SetActive (player1Name)
end name2Entered

proc a
end a

proc b
end b

proc c
end c

proc d
end d

proc e
end e

proc f
end f

proc g
end g

proc h
end h

proc i
end i

proc j
end j

proc k
end k

proc l
end l

proc m
end m

proc n
end n

proc o
end o

proc p
end p

proc q
end q

proc r
end r

proc s
end s

proc t
end t

proc u
end u

proc v
end v

proc w
end w

proc x
end x

proc y
end y

proc z
end z

font := Font.New ("Kozuka Gothic Pro EL:60")
font2 := Font.New ("Kozuka Gothic Pro EL:24:bold")
Font.Draw ("Welcome to Hangman", 65, 880, font, white)
Font.Draw ("Please Enter Names: ", 65, 550, font2, white)

player1Name := GUI.CreateTextFieldFull (65, 500, 100, "",
    nameEntered, GUI.INDENT, 0, 0)

player2Name := GUI.CreateTextFieldFull (65, 450, 100, "",
    name2Entered, GUI.INDENT, 0, 0)
continue := GUI.CreateButtonFull (65, 400, 40, "Enter", enter, 40, '^D', true)

% This a temprorary patch to help the program stay together
delay (3000)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

GUI.Dispose (player1Name)
GUI.Dispose (player2Name)
GUI.SetBackgroundColor (72)

quitter := GUI.CreateButtonFull (100, 380, 100, "Quit (Ctrl+Q)", GUI.Quit, 40, '^Q', true)
GUI.SetColor (quitter, 65)

aButton := GUI.CreateButtonFull (100, 500, 40, "A", a, 40, '^D', true)
GUI.SetColor (aButton, white)
bButton := GUI.CreateButtonFull (160, 500, 40, "B", b, 40, '^D', true)
GUI.SetColor (bButton, white)
cButton := GUI.CreateButtonFull (220, 500, 40, "C", c, 40, '^D', true)
GUI.SetColor (cButton, white)
dButton := GUI.CreateButtonFull (280, 500, 40, "D", d, 40, '^D', true)
GUI.SetColor (dButton, white)
eButton := GUI.CreateButtonFull (340, 500, 40, "E", e, 40, '^D', true)
GUI.SetColor (eButton, white)
fButton := GUI.CreateButtonFull (400, 500, 40, "F", f, 40, '^D', true)
GUI.SetColor (fButton, white)
gButton := GUI.CreateButtonFull (460, 500, 40, "G", g, 40, '^D', true)
GUI.SetColor (gButton, white)
hButton := GUI.CreateButtonFull (520, 500, 40, "H", h, 40, '^D', true)
GUI.SetColor (hButton, white)
iButton := GUI.CreateButtonFull (580, 500, 40, "I", i, 40, '^D', true)
GUI.SetColor (iButton, white)
jButton := GUI.CreateButtonFull (640, 500, 40, "J", j, 40, '^D', true)
GUI.SetColor (jButton, white)

kButton := GUI.CreateButtonFull (100, 440, 40, "K", k, 40, '^D', true)
GUI.SetColor (kButton, white)
lButton := GUI.CreateButtonFull (160, 440, 40, "L", l, 40, '^D', true)
GUI.SetColor (lButton, white)
mButton := GUI.CreateButtonFull (220, 440, 40, "M", m, 40, '^D', true)
GUI.SetColor (mButton, white)
nButton := GUI.CreateButtonFull (280, 440, 40, "N", n, 40, '^D', true)
GUI.SetColor (nButton, white)
oButton := GUI.CreateButtonFull (340, 440, 40, "O", o, 40, '^D', true)
GUI.SetColor (oButton, white)
pButton := GUI.CreateButtonFull (400, 440, 40, "P", p, 40, '^D', true)
GUI.SetColor (pButton, white)
qButton := GUI.CreateButtonFull (460, 440, 40, "Q", q, 40, '^D', true)
GUI.SetColor (qButton, white)
rButton := GUI.CreateButtonFull (520, 440, 40, "R", r, 40, '^D', true)
GUI.SetColor (rButton, white)
sButton := GUI.CreateButtonFull (580, 440, 40, "S", s, 40, '^D', true)
GUI.SetColor (sButton, white)
tButton := GUI.CreateButtonFull (640, 440, 40, "T", t, 40, '^D', true)
GUI.SetColor (tButton, white)

uButton := GUI.CreateButtonFull (220, 380, 40, "U", u, 40, '^D', true)
GUI.SetColor (uButton, white)
vButton := GUI.CreateButtonFull (280, 380, 40, "V", v, 40, '^D', true)
GUI.SetColor (vButton, white)
wButton := GUI.CreateButtonFull (340, 380, 40, "W", w, 40, '^D', true)
GUI.SetColor (wButton, white)
xButton := GUI.CreateButtonFull (400, 380, 40, "X", x, 40, '^D', true)
GUI.SetColor (xButton, white)
yButton := GUI.CreateButtonFull (460, 380, 40, "Y", y, 40, '^D', true)
GUI.SetColor (yButton, white)
zButton := GUI.CreateButtonFull (520, 380, 40, "Z", z, 40, '^D', true)
GUI.SetColor (zButton, white)

loop
    exit when GUI.ProcessEvent
end loop





Please specify what version of Turing you are using
4.1.1

-----------------------------------
mitheralice
Tue Jun 03, 2014 7:29 pm

RE:Waiting for user input in Turing Game
-----------------------------------
Try the "get" command...
