Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI looping
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kk




PostPosted: Sat Jan 10, 2004 5:31 pm   Post subject: GUI looping

I have to make an email program and i'm currently working on the login screen with GUi that opens in a new window. can you use loops in gui ? because the problem is that i have a "login" button hat the user clicks to login and its action proc checks if the username and passwrod is correct. the action proc is before the commands declaring the gui buttons and text fields in hte program. If the name and password are incorrect, i want to "loop" the whole process again, but i don't see any way to do this since the gui commands are after the action procedure.

Also.. can you have
loop
exit when GUI.ProcessEvent
end loop
multiple times in your program? does there have to be some sort of order as to where you put it, or can you just have your whole program and stick that event loop at the very end?

Here's the program:
code:

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)
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Jan 10, 2004 5:59 pm   Post subject: (No subject)

well before you could only have a single exit when loop that was driving your whole interface... but now we have a tutorail on how to modify the GUI module code so that you can use exit when loop multiple times Wink I think you would find that useful.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
kk




PostPosted: Sat Jan 10, 2004 6:20 pm   Post subject: (No subject)

is there some way i could "loop" the action procedure and return the user back to the main program from the action procedure of any particular button?

i saw that tutorial, but i'm handing this in - can the teacher's computer have the modified GUI thing.........?
Tony




PostPosted: Sat Jan 10, 2004 10:17 pm   Post subject: (No subject)

well no... what you can do is just have all the GUI files are your files and link to another location... or just compile the program Wink

ether way, I'm not too sure of Turing's GUI working... I use VB instead 8)

what you might have to do is to destory and recreate your forms in the loops... such as
code:

loop %main
[create main form]
...
     [destroy main form]
     loop %seconadary
     [create secondary form]
     ...
     end loop
     [destory seconday form]
...
end loop %main
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: