Difference between revisions of "ScriptBasic:UsersGuide 10.2"

From ScriptBasic
Jump to: navigation, search
(New page: [Contents]<br /> :10. Interacting with the user<br /> =10.2. Input= [<<<] [[ScriptBasic:UsersGuid...)
 
(No difference)

Latest revision as of 00:07, 28 December 2007

[Contents]

10. Interacting with the user

10.2. Input

[<<<] [>>>]


ScriptBasic has the usual input statement, however a slightly different from other BASIC implementations. Input statement in other basic languages reads the keyboard and puts a string, real or integer number into the variable depending on the type of the variable. In ScriptBasic there is no type of the variables, any variable can hold any type of value. Thus the input statement can not know if the input is to be read as integer, real or character string as typed.

Because of this ScriptBasic reads the characters as typed into the variable on the input statement as string. Because this is the usual behavior of the BASIC languages for the command line input ScriptBasic also names this statement LINE INPUT.

This command reads a whole line from the file specified after the # sign or from the standard input if no file number was specified. The string read is put into the variables listed on the command. Each variable gets a line including the line terminating new line character.


print "Give me a line:"
line input a
print "This is a=",a,"This was a\n"

To remove the new line from the end of the read string you can use the function chomp.


[<<<] [>>>]