Hello World 2

Home

Our second program, Hello World 2 is a program that also writes the words Hello World on the screen of your computer.  This time, however, you can control the color, size and font of the words on the screen.  You can even control where the words are written.  Here is the entire program.

Program HelloWorld

    Method Main()

        Color(Blue)

        Pen(False)

        MoveTo(250, 24)

        SetFont("Times New Roman" , 28 , True , True , True)

        Print("Hello World")

    End Method

End Program

 

Download KPL

Now lets look line by line:

This line sets the color.  Just change the word and see what happens:

    Color(Blue)

These two lines move the cursor to the center of the window before writing begins.  Change the numbers to change where the words appear on the screen.

    Pen(False)

    MoveTo(250, 24)

This line sets the font ("Times New Roman") and the font size (28).   The words True, True and True make the font bold, italic and underlined.   The font, size and other attributes can be changed.  Change the numbers and change the words true to false and see what happens.  You can even change Times New Roman to Ariel or Script MT Bold and see what happens.

    SetFont("Times New Roman" , 28 , True , True , True)

The final line of the program prints the words on the screen.

    Print("Hello World")

See if you can get the program to work, and then change the color, location and font size and characteristics.

Our next program shows how you can use a loop to make hello world appear many times on the screen.