var username : string
var password : string
var NAME, PASS : boolean
var LoginWin : int
var loginname : int
var loginpass : int
var namelbl, passlbl : int
var loginB : int %login button
%checks input is under specific lenth
fcn lngth_iput2 (word : string, lenth : int) : boolean
if length (word) <= lenth then
result true
else
result false
end if
end lngth_iput2
proc namme (text : string)
username := GUI.GetText (loginname)
put username
if lngth_iput2 (username, 10) then %if legnth(username )>10 then
drawfillbox (3, 20, 350, 35, white)
GUI.SetActive (loginpass)
else
Font.Draw ("Your username must be no longer than 10 characters", 10, 20, font1, black)
GUI.SetText (loginname, "")
end if
end namme
proc passs (text : string)
password := GUI.GetText (loginpass)
put password
if lngth_iput2 (password, 9) then %if password <=9
drawfillbox (5, 20, 350, 35, white) %draws over erroe msg
GUI.SetActive (loginname)
GUI.Enable (loginB)
else
Font.Draw ("Your password must be less than 10 characters", 10, 20, font1, black)
GUI.SetText (loginpass, "")
end if
end passs
proc login %determine=1 for creating new account
loc := 0
file_search3 (NAME, username, loc)
file_search3 (PASS, password, loc)
put "N", NAME
put "P", PASS
if NAME = false or PASS = false then
if NAME = false then
Font.Draw ("This account doesn't exist", 10, 20, font1, black)
GUI.SetText (loginname, "")
GUI.SetText (loginpass, "")
elsif PASS = false then
Font.Draw ("Please reenter your password", 10, 20, font1, black)
GUI.SetText (loginpass, "")
GUI.SetActive (loginpass)
end if
end if
end login
LoginWin := Window.Open ("graphics:400;400")
Window.SetPosition (LoginWin, 300, 300)
NAME := false
PASS := false
loginB := GUI.CreateButtonFull (100, 50, 0, "login", login, 0, "l", false)
GUI.Disable (loginB) %enabled when login and passwrod are have text within lenght(input) limits
namelbl := GUI.CreateLabelFull (75, 200, "LOGIN", 20, 0, GUI.RIGHT, font1)
loginname := GUI.CreateTextFieldFull (100, 200, 200, "", namme, GUI.INDENT, 0, 0)
passlbl := GUI.CreateLabelFull (75, 100, "PASSWORD", 20, 0, GUI.RIGHT, font1)
loginpass := GUI.CreateTextFieldFull (100, 100, 200, "", passs, GUI.INDENT, 0, 0)
loop
exit when GUI.ProcessEvent
end loop
GUI.CloseWindow (LoginWin) |