Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing char type input after a previous input includes a space or blank line #8

Open
aitorres opened this issue Mar 31, 2017 · 1 comment

Comments

@aitorres
Copy link

Consider the following program:

program Chars begin

main |[
	var x : char

  ; write("First try: ")
  ; read(x)
  ; writeln("Your input: ", x)
 
  ; write("Second try: ")
  ; read(x)
  ; writeln("Your input: ", x)

  ; write("Third try: ")
  ; read(x)
  ; writeln("Your input: ", x)
]|
end

If any input is consistent of a blank line (pressing the "Enter"/Return key) and then any other character (which is parsed as a single input), or an empty space (' ') any following read char will be parsed as a blank line, no matter the input. For example, on the following run, my inputs are "1", "2", "3" in order. This is the output:

aitorres@fibonacci:~$ rungraciela chars.gcl 
First try:  
1
Your input: 

Second try: 2
Your input: 

Third try: 3
Your input: 


It still does not work even if I change variables. Consider the following program:

program Chars2 begin

main |[
	var x, y, z : char

  ; write("First try: ")
  ; read(x)
  ; writeln("Your input: ", x)
 
  ; write("Second try: ")
  ; read(y)
  ; writeln("Your input: ", y)

  ; write("Third try: ")
  ; read(z)
  ; writeln("Your input: ", z)
]|
end

With the same input as before, the output is:

aitorres@fibonacci:~$ rungraciela chars2.gcl 
First try: 
1
Your input: 

Second try: 2
Your input: 

Third try: 3
Your input: 


Any combination of inputs with no blank lines () or spaces before works as expected.

Note that this error makes it difficult to deal with player input for the Minesweeper project of CI-2691 (Universidad Simón Bolívar) for this term.

@aitorres
Copy link
Author

After doing some tests, this error happens after more than one char is tried to be inputed at a char input. For example, in any of the previous example programs, inputing "22" or " 2" or "a8" or any combination of two or more characters will accept the input, parse it in a certain way (given by the first char) and then any following input will not be read, defaulting to a blank line/space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant