I don't understand GetChar() very well

33 views
Skip to first unread message

Ahmed Shendy

unread,
Feb 7, 2016, 5:39:00 PM2/7/16
to The Ring Programming Language
Hello,
I didn't understand well the GetChar() function. Could anyone please explain it in more details.
I tried to comment this like
"GetChar() GetChar() # End of line"
but I got behavior I could not understand.


--
Thanks,
Shendy

amr ESSAM

unread,
Feb 7, 2016, 5:59:12 PM2/7/16
to The Ring Programming Language
What behavior you didn't understnad ?

and btw you can check this link about inputs, http://wp.me/p7aUcp-9u.

Ahmed Shendy

unread,
Feb 7, 2016, 6:05:21 PM2/7/16
to The Ring Programming Language
Why the line I comment it makes difference in the output?

amr ESSAM

unread,
Feb 8, 2016, 8:53:55 AM2/8/16
to The Ring Programming Language
It actually doesn't, i didn't understand too but when i tried i saw no difference in the results.

Mahmoud Fayed

unread,
Feb 8, 2016, 9:30:21 AM2/8/16
to The Ring Programming Language
Hello Ahmed

The GetChar() function accept one character from the keyboard buffer

In this example


While True
        See "
                Main Menu
                (1) Say Hello
                (2) Exit
            "
        Option = GetChar()

        GetChar() GetChar()  # End of line

        # the previous two lines can be replaced with the next line
        # Give Option

        if Option = 1
                see "Enter your name : " give cName
                see "Hello " + cName
        else
                bye
        ok
End


We uses GetChar() Three times
The first time we get the user option

Option = GetChar() 

But in the second and the third time (We accept the new line characters from the buffer)


GetChar() GetChar()  # End of line

Example : when the user select the option number 1 then press ENTER
We have Three Characters
The first character is : Number 1
The second character is : CHAR(13)
The third character is : CHAR(10)
because Windows uses CHAR(13) and CHAR(10) for new line  ( i.e. CR+LF )

Greetings,
Mahmoud

Ahmed Shendy

unread,
Feb 8, 2016, 1:56:07 PM2/8/16
to The Ring Programming Language
There is a difference in how output displayed on console

Ahmed Shendy

unread,
Feb 8, 2016, 1:57:26 PM2/8/16
to The Ring Programming Language
Hello Eng.Mahmoud,

Now I understand it.

Mahmoud Fayed

unread,
Feb 8, 2016, 2:48:45 PM2/8/16
to The Ring Programming Language
You are welcome :D

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages