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

Username:   Password: 
 RegisterRegister   
 better way to do this?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
unknowngiver




PostPosted: Thu May 25, 2006 4:35 pm   Post subject: better way to do this?

Hey
is there a better way to do this?
i have a navigation bar and i want to check what button is clicked and then display that stuff
this is wt my teacher told me to do but i dont like it..as when i have more buttons it will be really crappy

code:

if page_main = true then

    GameServer.main_content (serverAddress + "maincontent.txt")
end if

loop

    if page_reg = true then
        cls
        render.bg
        GameServer.reg (serverAddress + "register.php")
        exit
    end if

end loop

that is to check what page is clicked and then to display that content
and then i have to do this everytime someone clicks a button

code:

                page_main := false
                page_reg := true

thats if the registertaion button is clicked
but when i have alot of buttons i will have a HUGE program
since i will have to define everything false n only the button that is clicked true for every button..and so on...is there is a better way of doing this? both checking what page is on and also putting it on the screen/
thanks
Sponsor
Sponsor
Sponsor
sponsor
Remm




PostPosted: Thu May 25, 2006 6:24 pm   Post subject: (No subject)

Erm, so you mean like when you click a button, what code should be used to go to a different page? / how to manage it?
Tony




PostPosted: Thu May 25, 2006 6:42 pm   Post subject: (No subject)

you could have an array of boolean values. This way you can reset the entire group to false inside a forloop, and then use index to set the flags/buttons you want to true.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
unknowngiver




PostPosted: Thu May 25, 2006 7:19 pm   Post subject: (No subject)

Tony: i understood the array of boolean part...but not the index part...can u please explain it? maybe give an example or something
thanks Very Happy
unknowngiver




PostPosted: Mon May 29, 2006 9:49 am   Post subject: (No subject)

still waiting
wtd




PostPosted: Mon May 29, 2006 12:35 pm   Post subject: (No subject)

A small note:

code:
if page_main = true then


Is exactly the same as:

code:
if page_main then


You should use words like "is" in boolean variable names.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: