
-----------------------------------
rated
Fri May 02, 2008 5:54 pm

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 :)

Heres the basic version of my program


 
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




-----------------------------------
Tony
Fri May 02, 2008 7:03 pm

Re: help with program using procedure and getchar
-----------------------------------
is there anyway to hide that little blinking box

That's called the cursor. You can set your view to not display that.

View.Set("nobuttonbar;nocursor")


You might also find [url=http://compsci.ca/v3/viewtopic.php?t=17984]this topic to be of use.

-----------------------------------
rated
Fri May 02, 2008 7:13 pm

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 :)

-----------------------------------
rated
Sat May 03, 2008 1:53 pm

RE:help with program using procedure and getchar
-----------------------------------
Im just wondering what is the difference between getchar and getch?

-----------------------------------
Tony
Sat May 03, 2008 1:59 pm

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.
