Certification 1 Programming Topics • There are several ways to put

advertisement
Certification 1 Programming Topics
•
•
There are several ways to put text out to the screen. The PRINT and TEXT commands are the primary
commands for accomplishing this task.
PRINT
o PRINT will print at the current cursor position.
o PRINT can be followed by a string literal or a variable name
o PRINT values can be separated by a comma, which will insert a tab
o String values can be concatenated to form bigger strings
o The Str$ command must be used when concatenating strings and numbers
o The Chr$ command will convert a number into its ASCII value
o The ASC command will return the ASCII numeric value of a character
o LEN will return the length of a string
o MID$, LEFT$, and RIGHT$ can be used to return a portion of a string
•
SET CURSOR
o This command can be used to position the cursor on the screen. It is usually followed by the
PRINT command
o The syntax is SET CURSOR X, Y
•
TEXT
o
o
o
o
o
o
o
o
TEXT is like SET CURSOR and PRINT combined
TEXT is like PRINT but requires an X and Y coordinate for text placement
The syntax is TEXT X, Y, String$
CENTER TEXT will center text around the specified X and Y coordinates
The syntax is CENTER TEXT X, Y, String$
The font can be changed by using the SET TEXT FONT “fontname” command
The font size can be changed by using the SET TEXT SIZE 99 command
The font style can be changed by using the SET TEXT TO style command. The styles you can
use are NORMAL, BOLD, ITALIC, and BOLDITALIC
o Each character in DarkBASIC is actually in a square. This can be a problem if putting text over
a graphic. SET TEXT TRANSPARENT will make the square clear. SET TEXT OPAQUE will
return color to the square.
•
DO…LOOPS
o The syntax is DO
Command 1
Command 2
Command 3
Command 4
LOOP
o Do loops are infinite. It is your responsibility as a programmer to check the condition within the
loop and use the EXIT command once the condition is met.
Download