Blitz:Shell Input/Output

From Amiga Coding
Revision as of 12:27, 23 July 2015 by Daedalus (talk | contribs)
Jump to: navigation, search

Input and output using the shell is quite simple in Blitz Basic / AmiBlitz, and generally similar to most other BASIC dialects.

Print / NPrint

The Print statement is used to print one or more items directly to the shell window. Each argument will be shown directly after the previous argument with no space in between so you need to separate your items yourself if needed. For example:

a = 6 Print "The value of a is", a Will show the following in the shell window:

The value of a is6

Adding spaces to the messages fixes the output: a = 6 Print "The value of a is ", a Any combination of arguments is possible: string constants (which are surrounded by quote marks), string variables, constants, numerical variables, numerical expressions, or returned values of a function.

Print will leave the cursor exactly at the end of what ever is output to the console, so Print "Message 1" Print "Message 2" will output Message1Message2 NPrint is almost identical to Print, except that it adds a newline at the end of its output. So NPrint "Message 1" NPrint "Message 2" will output Message1 Message2

Note: At least one argument is required for Print/NPrint statements. So, unlike other BASICs, to skip a line you need to provide something to print. In this case, a null string can be used. For example: NPrint "Message 1" NPrint "" NPrint "Message 2" will output Message1

Message2

AmiBlitz added the ability to include escape characters in strings. See String Handling for more information.