Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

QBasic/Advanced Text Output

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Cursor manipulation As you try to write your text editor, you may realize that you will need to place the cursor in a given location on the screen. This is performed using the LOCATE statement. Printing any character in the bottom-right corner of the screen will cause the display to scroll. Color To change the current printing color, use the COLOR statement. COLOR 7,0 'Uses the default white on black. COLOR 15,0 'Bright white on black. COLOR 0,1 'Black on blue COLOR 14,0 'Bright yellow. This can be used for title or status bars at the bottom. Formatted printing The PRINT USING statement allows you to output strings or numbers in a specified format. With this statement, you can write numbers out to specified decimal places or perform advanced output. The most common format specifiers would be # and ., which reserve space for digits and decimal points respectively. You may also use the underscore to ensure that a given character is printed literally. Note: PRINT USING is unable to add leading zeros to a number. E.g., if you specify 3 digits (###), a two digit number will be output with leading spaces. Text animation You require some time before doing a certain procedure. It is generally better to make an animation during the process which shows that the program has not hanged, but is going on. Why make that out of very complicated graphics? Use this: <syntaxhighlight lang = QBasic> SUB TEXT_ANIM X = 15 ' CAN BE ANY OTHER VALUE TOO Y = 15 ' CAN BE ANY OTHER VALUE LOCATE Y,X DO PRINT "> " SLEEP 1 CLS PRINT " > " SLEEP 1 CLS PRINT " > " SLEEP 1 CLS PRINT " > " SLEEP 1 CLS PRINT " > " SLEEP 1 CLS PRINT " >" SLEEP 1 CLS LOOP UNTIL INKEY$ <> "" END SUB </SOURCE> The program uses INKEY$, which you have not learnt yet, and SLEEP and DO...LOOP, which also you have not learnt. For more information, refer to Flow Control and Appendix.