Computer Science Canada

Why isn't the input working? Look to see code

Author:  noobsauce [ Tue Oct 14, 2008 6:14 pm ]
Post subject:  Why isn't the input working? Look to see code

Here is the code:
var name : string (100)
var timetoexit : char
loop
locate (8, 12)
get name : *
cls
get timetoexit
exit when timetoexit = 'n'
end loop
for some reason turing only get the name 1ce, it skips the input for name after the first time? Anyone know what is wrong and how i can fix it? thanks

Author:  The_Bean [ Tue Oct 14, 2008 7:06 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

I believe that it's the ": *" after get name that is causing the problem.

Author:  noobsauce [ Tue Oct 14, 2008 7:10 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

So do I have to input name as different strings, or is there an alternative way?

Author:  andrew. [ Tue Oct 14, 2008 7:10 pm ]
Post subject:  RE:Why isn\'t the input working? Look to see code

You declared the variable as 100 characters in the string, I think you should take out the 100 in the declaration, or you should change the * to 100.

Author:  The_Bean [ Tue Oct 14, 2008 7:13 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

To fix this turn timetoexit into a string of length 1
and use getch(timetoexit)
Turing:

var timetoexit : string(1)
getch (timetoexit)

Author:  noobsauce [ Tue Oct 14, 2008 7:13 pm ]
Post subject:  Re: RE:Why isn\'t the input working? Look to see code

andrew. @ Tue Oct 14, 2008 7:10 pm wrote:
You declared the variable as 100 characters in the string, I think you should take out the 100 in the declaration, or you should change the * to 100.

Doesn't seem to be workjing Sad I've tried both method but the program still ignoring the the fact that I put get name

Author:  noobsauce [ Tue Oct 14, 2008 7:16 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

The_Bean @ Tue Oct 14, 2008 7:13 pm wrote:
To fix this turn timetoexit into a string of length 1
and use getch(timetoexit)
Turing:

var timetoexit : string(1)
getch (timetoexit)

Doesn't work perfectly as it skips the input for name right after but is fine for the time after, so wasted a loop everytime i type name-.-

Author:  The_Bean [ Tue Oct 14, 2008 7:19 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

You might not have put them in the right spot. Those two lines were just what you should replace the others with, they shouldn't appear like that in the code.

Author:  noobsauce [ Tue Oct 14, 2008 7:25 pm ]
Post subject:  Re: Why isn't the input working? Look to see code

Thanks, works perfect:D


: