Centering Text On The Screen

Simple example how to center text on middle of screen with QBasic/FreeBASIC.

DIM Words$(15) ' Makes an array

SCREEN 0: WIDTH 80, 50: CLS:COLOR 6 ' Set's the screen

' Ok, you know what now happens
Words$(0) = "There is a world that started to"
Words$(1) = "exist in a same moment than human."
Words$(2) = "But so sad as it sounds, only few human's can understand"
Words$(3) = "that it's there somewhere and lives beside world of our's"
Words$(4) = "So near that you could allmost touch it"
Words$(5) = "but also so far away that human mind's cant understand it."
Words$(6) = "And just like a world of our's"
Words$(7) = "that world has changed and evolved all the time."
Words$(8) = "That world is so mutch same kind than our's"
Words$(9) = "that it could easily feel like a home."
Words$(10) = "But's it's also so mutch different,"
Words$(11) = "that you or i, probably could survive there more than a few moments."
Words$(12) = "Like this world of our's, that world has also tales to keep it alive."
Words$(13) = "I know one story from that world,"
Words$(14) = "and this is the way how i want to share it with you."
Words$(15) = "And if you are clever enough, you find out where's that exciting world is."

x = 2 'Starting location of X line
FOR i = 0 TO 15 ' Because Words$(X) = 15

FOR y = 1 TO LEN(Words$(i)) ' How many characters is on Words$(i)

LOCATE x + i, (40 - INT(LEN(Words$(i)) / 2) + y) ' Try to understand =)
PRINT MID$(Words$(i), y, 1) ' And this one too =)

NEXT y

NEXT i

SLEEP ' To see results
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.