CASIO BASIC programming tips: Text display functions
by sonone, May 9, 2022, 11:26 PM
Text display functions
In programs, you can utilize two different display windows: the graphing window and the text window. The graphing window if where graphing and any type of drawing happens, and the text window is for almost everything else (I say almost, because there are list, table and matrix views, which are different beasts in themselves). I will be focusing on the text window display functions which display text and strings.
The first and easiest is just string output. Simply place a string in its own line and it will print in the console. For example,
just prints out TEXT to the console.
Akin to this is the output function. It is a little triangle in the pgrm menu which acts the same as the simple string output, except that it requires you to press EXE to continue program execution. If the argument is a string, the display is left flushed, but if it is a number or variable, it is right flushed. For example (/ means the output function):
gives
<Press EXE>
<Press EXE again>
Note: if you use the output function as the last call of your program, it will re-display the last outputted value once you press EXE and then exit the program if you press it again.
The last display function, found in the I/O of prgm menu, is Locate. This is my favorite display function because I can put anything I want on the text window anywhere. The syntax is
The following code puts 7 A's in a diagonal line:
A more efficient code using a for loop
Output:
For my coding I generally use the first two display functions in computational programs, while I almost exclusively use Locate for any games. I will cover the basic graphing displays in another post.
In programs, you can utilize two different display windows: the graphing window and the text window. The graphing window if where graphing and any type of drawing happens, and the text window is for almost everything else (I say almost, because there are list, table and matrix views, which are different beasts in themselves). I will be focusing on the text window display functions which display text and strings.
The first and easiest is just string output. Simply place a string in its own line and it will print in the console. For example,
"TEXT"
just prints out TEXT to the console.
Akin to this is the output function. It is a little triangle in the pgrm menu which acts the same as the simple string output, except that it requires you to press EXE to continue program execution. If the argument is a string, the display is left flushed, but if it is a number or variable, it is right flushed. For example (/ means the output function):
"PRESS EXE"/
3/
"TEXT"
gives
PRESS EXE
-Disp-
<Press EXE>
PRESS EXE
3
-Disp-
<Press EXE again>
PRESS EXE
3
-Disp-
TEXT
Note: if you use the output function as the last call of your program, it will re-display the last outputted value once you press EXE and then exit the program if you press it again.
The last display function, found in the I/O of prgm menu, is Locate. This is my favorite display function because I can put anything I want on the text window anywhere. The syntax is
Locate <COL 1-21>, <ROW 1-7>, <arg (str, var, num etc)>
The following code puts 7 A's in a diagonal line:
Locate 1,1,"A"
Locate 2,2,"A"
Locate 3,3,"A"
Locate 4,4,"A"
Locate 5,5,"A"
Locate 6,6,"A"
Locate 7,7,"A"
A more efficient code using a for loop
For 1->I To 7
Locate I,I,"A"
Next
Output:
A
A
A
A
A
A
A
For my coding I generally use the first two display functions in computational programs, while I almost exclusively use Locate for any games. I will cover the basic graphing displays in another post.