Herramientas de usuario

Herramientas del sitio


en:locomotive:aplicaciones:basic:input_sin_signo_de_interrogacion

A> INPUT WITHOUT QUESTION MARK
DESCRIPTION
The BASIC INPUT statement is a useful way to ask questions and gather answers from the user while a program is running. For example, to ask someone for their name, you can use the program line: 10 INPUT "Name ;";name$. When the program runs, Name? is printed on the screen (notice that the question mark is automatically added), the system waits for the user to type their name and press [RETURN], and then stores the result in the name$ variable. However, there are some interesting variations you can apply to this method.
1. To prevent the question mark from automatically appearing at the end, use a comma instead of a semicolon right after the text enclosed in quotation marks. Thus, the instruction INPUT "Press <RETURN>",zzz displays 'Press <RETURN>' on the screen and waits for the user to do so. As a side effect, the variable zzz is assigned a value of zero, but you can simply ignore it.
2. To save the trouble of always having to press [RETURN], a different technique can be used. If you want to prompt the user to 'press any key to continue', you can use the lines provided in the source code listing.
SOURCE CODE
10 zzz$="" 20 PRINT "Press any key to continue" 30 WHILE zzz$ ="" 40 zzz$ = INKEY$ 50 WEND
DIGITAL FILE

en/locomotive/aplicaciones/basic/input_sin_signo_de_interrogacion.txt · Última modificación: por jesus