PDA

View Full Version : Problem reading in keyboard data



GSAC3
24-01-2009, 00:23
Eros:

In the following code, I am trying to read in and then print out data entered from the keyboard, but I am not getting the correct results (at least not what I am expecting to get).

'
Uses "Console"

DIM Z AS STRING
DIM D AS INTEGER

PRINTL ("ENTER number (e.g. 1) ")
Z = GETS()
PRINTL (Z)
D = VAL(Z)
PRINTL Str$(D)
SLEEP (5000)

When I enter a numerical value, say 1, from the keyboard, the string value printed out by the code is 0 (zero) instead of 1. I believe I am following the documentation correctly for using GETS(), VAL(Z), and Str$(D), but I must be doing something wrong. I am using version 1.7.5.0.

Don

Michael Clease
24-01-2009, 00:54
try this

PRINTL ("ENTER number (e.g. 1) ")
z = Console_Read()

GSAC3
24-01-2009, 03:21
Michael--

Thanks for you'r reply. You's solution works fine, but I still don't understand why GETS() won't.

Don

ErosOlmi
24-01-2009, 09:00
GETS is an alias of CGI_Read and it deals with standard input in CGI web applications.
In those kind of applications there are other things to consider and keyboard usually is not included.

For Console applications always use CONSOLE_... commands.

Ciao
Eros