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

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




PostPosted: Mon Nov 22, 2004 5:34 pm   Post subject: Help With GUI Login

I need to know how to use the vars to do if for proc 2
code:

%%%%%%%%%%%%%
%Imports GUI%
%%%%%%%%%%%%%

import GUI

var Name : string
var NameTxt : int
var pin, counter, balance1, change, cash, newpin : int := 0
var yesno : string
var account, info : string
const pathName : string := "temp.txt"
var streamNumber : int
var oldpass : string
var newpass : string := " "
var count := 0
var passwrd : string
var changeBtn : int
var usersBtn : int
var contBtn : int
var login1 : int
var quitBtn : int
var infobtn : int
var backBtn : int
var Pass : string
var PassTxt : int
var next : int
var cancel : int
var cancel2 : int
var NameLabel : int
var Pass2 : int
var win := Window.Open ("graphics:800;600")

%%%%%%%%%%%%%%%%
%Forwards Procs%
%%%%%%%%%%%%%%%%

forward procedure login
forward procedure balance
forward procedure user
forward procedure two
forward procedure password
forward procedure acclogin
forward procedure info1
forward procedure ext1
% forward procedure Pchange
forward procedure reset
forward procedure reset2
forward procedure reset3
forward procedure reset4
forward procedure reset5
forward procedure reset6
forward procedure reset7
forward procedure reset8
forward procedure reset9

%%%%%%%%%%%%%%%%%%%%%%%%%
%Called For Account Text%
%%%%%%%%%%%%%%%%%%%%%%%%%

procedure TextEntered (text : string)
    Name := GUI.GetText (NameTxt)
    account := Name
end TextEntered

%%%%%%%%%%%%%%%%%%%%%%%%%%
%Called For Password Text%
%%%%%%%%%%%%%%%%%%%%%%%%%%

procedure PassEntered (test : string)
    Pass := GUI.GetText (PassTxt)
    newpass := Pass
end PassEntered

%%%%%%%%%%%%%%%%%%%%%%%
%Used For User Balance%
%%%%%%%%%%%%%%%%%%%%%%%

body procedure balance
    put "Your Current Balance Is : ", balance1
    put "What Do You Wish To Change It To : " ..
    get change
    balance1 := change
    cls
    two
end balance

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Change Password Procedure%
%%%%%%%%%%%%%%%%%%%%%%%%%%%

% body procedure Pchange
% loop
%     %colour (include "Cgeneral.txt")
%     put ""
%     put "Input your old password"
%     put "~~>Turex~>Password Changer~>"..
%     %colour(include "Cinput.txt")
%     get text
%     %colour(include "Cgeneral.txt")
%     if text = back then
%         return
%     end if
%     if text = oldpass then
%     loop
%         put ""
%         put"Input new password : "..
%         %colour(include "Cinput.txt")
%         get newpass
%         %colour(include "Cgeneral.txt")
%         if newpass = back then
%             return
%         end if
%         put "The new password is: (y/n)"
%         put newpass
%         %colour(include "Cinput.txt")
%         get choice
%         colour(include "Cgeneral.txt")
%         if choice = "y" then
%             oldpass := newpass
%             flName := "temp.txt"
%             open : streamNumber, flName, put
%             text := "'" + oldpass + "'"
%             put : streamNumber, text
%             close : streamNumber
%             return
%         elsif choice = "n" then
%             exit
%         end if
%     end loop
%     else
%         put "That is not the old password."
%     end if
% end loop
% end Pchange

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Allows Person To Delete Users%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

body procedure user
    cls
    loop
        put "1.Howie"
        put "2.Admin"
        put "3.Mod"
        put "User You Wish To Delete : " ..
        get change
        if change = 1 then
            put "Are You Sure (y/n) : " ..
            get yesno
        elsif change = 2 then
            put "You Do Not Have Rights To Delete This User"
            cls
            return
        elsif change = 3 then
            put "Are You Sure (y/n) : " ..
            get yesno
            cls
            exit
        end if
    end loop
end user

%%%%%%%%%%%%%%%
%Account Login%
%%%%%%%%%%%%%%%

body procedure two
    if account = "admin" or account = "Admin" then
        balance1 := balance1 + 10000
        put "Welcome Adminastator"
        changeBtn := GUI.CreateButtonFull (50, 500, 0, "Change Account Balance",
            reset6, 0, '^D', false)
        usersBtn := GUI.CreateButton (50, 450, 60, "Delete Users", reset7)
        contBtn := GUI.CreateButton (50, 400, 60, "Change Password", two)
    elsif account = "Mod" or account = "mod" then
        loop
            put "Welcome Moderator"
            put "1.Delete Users"
            put "Enter A Number : " ..
            get info
            if info = "1" then
                put "1.Howie"
                put "2.Admin"
                put "3.Mod"
                put "User You Wish To Delete : " ..
                get change
                if change = 1 then
                    put "Are You Sure (y/n) : " ..
                    get yesno
                elsif change = 2 then
                    put "You Do Not Have Rights To Delete This User"
                    exit
                elsif change = 3 then
                    put "You Do Not Have Rights To Delete This User"
                end if
            end if
        end loop
    elsif account = "Howie" or account = "howie" then
        balance1 := balance1 + 1747
        loop
            put "Welcome Howie"
            put "1.Withdraw Cash"
            put "2.Change Pin"
            put "3.View Pin"
            put "What Would You Like To Do : " ..
            get info
            loop
                loop
                    if info = "1" then
                        put "Your Balance Is ", balance1
                        put "How Much Do You Wish To Withdraw : " ..
                        get cash
                        if cash = balance1 then
                            put "You Will Not Have Any Money Left"
                            put "Do You Still Wish To Withdraw (y/n) : "
                            get yesno
                            if yesno = "y" then
                                balance1 := 0
                                exit
                            end if
                        elsif cash > balance1 then
                            put "You Cannot Take More Then You Have"

                        else
                            balance1 := -cash
                            two
                        end if
                    elsif info = "2" then
                        put "Enter Your Current Pin : " ..
                        get pin
                        if pin = 1111 then
                            put "Enter New Pin : " ..
                            get newpin
                            pin := newpin
                            put "Pin Changed"
                            delay (500)
                            cls
                            two
                        else
                            put "That Is Not The Old Pin"
                            delay (500)
                            cls
                        end if
                    else
                        delay (500)
                        cls
                        put "Your Current Pin Is ", pin
                        delay (1000)
                        cls
                        two
                    end if
                end loop
            end loop
        end loop
    end if
end two

%%%%%%%%%%%%
%User Login%
%%%%%%%%%%%%

body procedure acclogin
    reset4
    cls
    cancel := GUI.CreateButtonFull (50, 500, 0, "Cancel",
        reset8, 0, '^D', false)
    next := GUI.CreateButton (200, 500, 0, "Next", reset3)
    var NameLabel : int := GUI.CreateLabel (20, maxy - 25, "Enter Your Account Name : ")
    NameTxt := GUI.CreateTextFieldFull (170, 573, 100, "", TextEntered, GUI.INDENT, 0, 0)
end acclogin

%%%%%%%%%%%%%%%%%%%%%
%Gets Pass From User%
%%%%%%%%%%%%%%%%%%%%%

body procedure password
    if File.Exists (pathName) then
    else
        open : streamNumber, pathName, put
        put : streamNumber, "'default'"
        close : streamNumber
    end if
    oldpass :=
    include "temp.txt"
    cls
    cancel2 := GUI.CreateButtonFull (50, 500, 0, "Cancel",
        reset9, 0, '^D', true)
    Pass2 := GUI.CreateButton (200, 500, 0, "Login", reset5)
    var PassLabel : int := GUI.CreateLabel (20, maxy - 25, "Enter Your Password : ")
    PassTxt := GUI.CreateTextFieldFull (140, 573, 100, "", PassEntered, GUI.INDENT, 0, 0)
    % loop
    %     if newpass = oldpass then
    %         put "Access Granted"
    %         cls
    %         two
    %         exit
    %     elsif newpass not = oldpass then
    %         put "Access Denied"
    %         count += 1
    %         delay (1200)
    %         cls
    %     end if
    % end loop
end password

%%%%%%%%%%%%%%%
%Exits Program%
%%%%%%%%%%%%%%%

body procedure ext1
    GUI.Quit
    Window.Close (win)
end ext1

%%%%%%%%%%%%%%%%%%%%
%Information Window%
%%%%%%%%%%%%%%%%%%%%

body procedure info1
    reset
    cls
    put "Made By Neo2385"
    put "Website http://stealth.t35.com"
    backBtn := GUI.CreateButton (50, 500, 0, "Back", reset2)
end info1

%%%%%%%%%%%%%
%Main Screen%
%%%%%%%%%%%%%

body procedure login
    cls
    login1 := GUI.CreateButtonFull (50, 500, 0, "Login",
        acclogin, 0, '^D', false)
    quitBtn := GUI.CreateButton (50, 400, 60, "Quit", ext1)
    infobtn := GUI.CreateButton (50, 450, 60, "Info", info1)
    loop
        exit when GUI.ProcessEvent
    end loop
end login

%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Main Buttons%
%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset
    GUI.Dispose (quitBtn)
    GUI.Dispose (infobtn)
    GUI.Dispose (login1)
end reset

%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Info Buttons%
%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset2
    GUI.Dispose (backBtn)
    login
end reset2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Disposes User Logon Buttons%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset3
    GUI.Dispose (cancel)
    GUI.Dispose (next)
    GUI.Dispose (NameTxt)
    password
end reset3

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Main Menu Buttons%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset4
    GUI.Dispose (quitBtn)
    GUI.Dispose (infobtn)
    GUI.Dispose (login1)
end reset4

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Password Buttons%
%%%%%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset5
    GUI.Dispose (Pass2)
    GUI.Dispose (PassTxt)
    cls
    two
end reset5

%%%%%%%%%%%%%%%%%%%%%%%
%Disposes User Buttons%
%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset6
    GUI.Dispose (changeBtn)
    GUI.Dispose (usersBtn)
    GUI.Dispose (contBtn)
    cls
    balance
end reset6

%%%%%%%%%%%%%%%%%%%%%%%
%Disposes User Buttons%
%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset7
    GUI.Dispose (changeBtn)
    GUI.Dispose (usersBtn)
    GUI.Dispose (contBtn)
    cls
    user
end reset7

%%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Logon Buttons%
%%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset8
    GUI.Dispose (cancel)
    GUI.Dispose (next)
    GUI.Dispose (NameTxt)
    cls
    login
end reset8

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Disposes Password Buttons%
%%%%%%%%%%%%%%%%%%%%%%%%%%%

body procedure reset9
    GUI.Dispose (cancel2)
    GUI.Dispose (Pass2)
    GUI.Dispose (PassTxt)
    cls
    login
end reset9

%%%%%%%%%%%%%%%%%%%%
%Calls In Main Proc%
%%%%%%%%%%%%%%%%%%%%

proc main
    login
end main
main
Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Wed Nov 24, 2004 11:17 am   Post subject: (No subject)

You can actually log in if you you type admin as your login, then push enter, then click next. What you need to do is change it so that when you click on the next button, it runs you TextEntered procedure with GUI.GetText as its parameter. This requires creating another procedure with no parameters that will be the procedure linked to the button. this procedure would simply call TextEntered. You should also set it up so that the TextEntered procedure calls the rest of the procedures that your next button calls, so that hitting enter from the text box does the same thing. A note: your password at this point is not checked.

Hope this helps!
neo2385




PostPosted: Wed Nov 24, 2004 4:21 pm   Post subject: (No subject)

Ok, well how can i do that? im sort of a newbe programmer
beard0




PostPosted: Thu Nov 25, 2004 3:33 pm   Post subject: (No subject)

neo2385 wrote:
Ok, well how can i do that? im sort of a newbe programmer

You do it by carefully reading through what I've written, and supposing that you have a problem understanding what I mean by a specific part of what I have said, you ask about that part specifically, and you try to write in code that makes sense. When you run your program, if you get an error message, you try to make sense of it, and change things so that you don't get the message any more. Once you have worked for a couple of hours on it, and are not making headway anymore, you post your code again with a clear request for help with something.

P.S. One more thing that I will say that may help you, is that the procedure that is linked to a text field is not called every time any key is pressed - only when the enter key is pressed.
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: