Computer Science Canada

Really Important .. and EASY :)

Author:  rulerruler [ Sun Jun 13, 2010 3:46 pm ]
Post subject:  Really Important .. and EASY :)

What is it you are trying to achieve?
I want to know how to change the color/ font size of the get command ; the input typed in.


What is the problem you are having?
I am using the "noecho" to make it invisible. but i am stuck at the "Input.KeyDown" command. So pleasee help. Any other option will do too.

Describe what you have tried to solve this problem
Like, i said, i am trying out the "Input.KeyDown" to solve this problem but i am stuck.. !


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
It's a menu i am trying to make :d

Turing:


<% Use the font
Font.Draw ("Menu", 0, 690, font4, purple)
Font.Draw ("1.Quiz", 0, 670, font2, purple)
Font.Draw ("2.Flashing Lights", 0, 650, font2, purple)
Font.Draw ("3.LED Connection", 0, 630, font2, purple)
Font.Draw ("4.Exit", 0, 610, font2, purple)
var choice: string :=""
Font.Draw ("Please select a menu choice by entering 1 , 2,  3, or 4", 0, 590, font3, purple)
View.Set ( "noecho" )       
locate (10,1) 
      Input.KeyDown (choice)
    delay (500)   
    if choice (1) then
        Font.Draw ("1", 0, 550, font2, blue)
        Font.Draw ("You Picked 1.", 0, 550, font2, blue)
        % put topic information here
        %then u put "cls" and then copy paste the quiz..
    elsif choice (2) then
        Font.Draw ("2", 0, 550, font2, blue)
        Font.Draw ("You Picked 2. Here is the quiz: is rohit ? yes or no?", 0, 550, font2, blue)
        % put topic information here
    elsif choice (3) then
        Font.Draw ("3", 0, 550, font2, blue)
        Font.Draw ("You Picked 3. Here is the quiz: is rohit ? yes or no?", 0, 550, font2, blue)
       
        % put topic information here
       
    elsif choice (4) then

        put "THANKS FOR TRYING THE PROGRAM"
        delay (3000)
        quit
    else
        put "you did not enter a correct number"
    end if
>



Please specify what version of Turing you are using
4.1.1

Author:  TheGuardian001 [ Sun Jun 13, 2010 3:58 pm ]
Post subject:  Re: Really Important .. and EASY :)

Well, for one thing, your Input.KeyDown is useless, firstly since Input.KeyDown uses array char of boolean, not string, and secondly since you overwrite it immediately afterward with the get statement.

Second, Input.KeyDown is probably not the best way to do this. What tends to work better is using getchar (which reads 1 character of input) in combination with hasch (which checks to see whether a key has been pressed without reading it.)

Essentially what you need to do is have a loop which checks for input using hasch, then, if the program has received input, reads that input with getchar and adds it to the end of a string. Basically:
code:

start loop
    if hasch
        add getchar to string
        exit when last character of string is ENTER
    end if
    draw current string
end loop

Author:  rulerruler [ Sun Jun 13, 2010 4:00 pm ]
Post subject:  Re: Really Important .. and EASY :)

well actually
i got it working!!!
code:

Font.Draw ("Menu", 0, 690, font4, purple)
Font.Draw ("1.Quiz", 0, 670, font2, purple)
Font.Draw ("2.Flashing Lights", 0, 650, font2, purple)
Font.Draw ("3.LED Connection", 0, 630, font2, purple)
Font.Draw ("4.Exit", 0, 610, font2, purple)
var choice : array char of boolean
Font.Draw ("Please select a menu choice by entering 1 , 2,  3, or 4", 0, 590, font3, purple)
View.Set ( "noecho" )       
locate (10,1) 
      Input.KeyDown (choice)
        delay (900)       
    if choice ('1') then
        Font.Draw ("1", 0, 550, font2, blue)
        Font.Draw ("You Picked 1.", 0, 570, font2, blue)
        % put topic information here
        %then u put "cls" and then copy paste the quiz..
    elsif choice ('2') then
        Font.Draw ("2", 0, 550, font2, blue)
        Font.Draw ("You Picked 2. Here is the quiz: is rohit ? yes or no?", 0, 570, font2, blue)
        % put topic information here
    elsif choice ('3') then
        Font.Draw ("3", 0, 550, font2, blue)
        Font.Draw ("You Picked 3. Here is the quiz: is rohit ? yes or no?", 0, 570, font2, blue)
       
        % put topic information here
       
    elsif choice (KEY_DOWN_ARROW) then

        put "THANKS FOR TRYING THE PROGRAM"
        delay (3000)
        quit
    else
        put "you did not enter a correct number"
    end if



: