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

Username:   Password: 
 RegisterRegister   
 help with program using procedure and getchar
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rated




PostPosted: Fri May 02, 2008 5:54 pm   Post subject: help with program using procedure and getchar

Hey guys Im new to turing but I have a assignment that requires me to teach the class about a certain topic so I chose the "history of telecommunications"
SO basically the user has to press a number on the keyboard corresponding to the subtopic. If he wants to go back to main menu he has to press e. The problem is after the user presses e (to go back to the main menu) he has to press the number twice on the keyboard for it to take him to the subtopic. For example, if the user presses 1, it will take him to subtopic 1. He then presses e to go back to the main menu. However, if he wants to go back to subtopic 1 again he has to press number 1 on the keyboard twice.

On another note is there anyway to hide that little blinking box (not sure what to call it lol)?

Im not sure why its doing this.

Any help will be appreciated. Thanks Smile

Heres the basic version of my program


Turing:

View.Set ("nobuttonbar")
var font4 : int
var key1 : char := '0'
var mainselect : char := '0'
%Main Menu
procedure menu
    cls
    setscreen ("graphics:max;max")
    locate (15, 60)
    font4 := Font.New ("Palatino:14")
    Font.Draw ("THE HISTORY OF TELECOMMUNICATION ", maxx div 2 - 100, 770, font4, black)
    Font.Draw ("(1) How it all started ", 450, 750, font4, black)
    mainselect := getchar
end menu
%Subtopic 1: How it all started
procedure subtopic1
    cls
    Font.Draw ("How it all started ", 450, 750, font4, black)
    Font.Draw ("Please press E to go back to main menu", 450, 700, font4, black)
    key1 := getchar
    if key1 = 'e' then
        menu
    else
        if key1 not= 'e' then
            subtopic1
        end if
    end if
end subtopic1
loop
    menu
    if mainselect = '1' then
        subtopic1
    end if
end loop


Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri May 02, 2008 7:03 pm   Post subject: Re: help with program using procedure and getchar

rated @ Fri May 02, 2008 5:54 pm wrote:
is there anyway to hide that little blinking box

That's called the cursor. You can set your view to not display that.
code:

View.Set("nobuttonbar;nocursor")


You might also find this topic to be of use.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rated




PostPosted: Fri May 02, 2008 7:13 pm   Post subject: RE:help with program using procedure and getchar

Ahh cursor...I knew it was something like that...thanks tony...ill look at that topic too Smile
rated




PostPosted: Sat May 03, 2008 1:53 pm   Post subject: RE:help with program using procedure and getchar

Im just wondering what is the difference between getchar and getch?
Tony




PostPosted: Sat May 03, 2008 1:59 pm   Post subject: RE:help with program using procedure and getchar

looking at the difference between two sources involved, I'm gonna assume that getchar is a function, while getch is a procedure working with a reference.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: