Background
SmileBASIC is a BASIC interpreter for the Nintendo 3DS.
Like most versions of BASIC, there is a PRINT
command which displays text in the console. (As well as ?
which does the same thing)
By default, PRINT
moves the cursor to the next row after printing, and this can be disabled by putting a semicolon after the last argument.
Problem
PRINT
without ;
does NOT output a trailing newline. This can be tested by comparing it with printing a real newline character:
PRINT "TEST1" 'print + move cursor
PRINT "TEST2"+CHR$(10); 'print + newline
Using CHKCHR
, you can see that TEST2
has a newline character after it, while TEST1
does not.
You can also use LOCATE
to move the cursor without printing newlines or other special characters.
newlines yes
Many challenges ask you to print lines of text separated by newlines (for example, ASCII art). Is it acceptable to move the cursor in a different way (using PRINT or LOCATE)?
newlines no
Other challenges specifically say that trailing newlines are not allowed. Should extra cursor movements not be allowed at all?
CHKCHR
work, and how does the system know to print on the next line? \$\endgroup\$CHKCHR(x,y)
returns the ASCII code of the character at x,y in the console. When a newline is printed, the cursor x position is set to 0, and the y position is set to the current line + 1. I guess PRINT just does the same thing on its own. \$\endgroup\$