Print

( PlayBasic v1.61 )

Print display a message

Syntax

Print message

  • message - message to display

Description

Print displays a message to the player of your game. The message can be a string, integer, or floating point number. Unlike the traditional BASIC implementation of PRINT, using Print without an argument does not display a blank line.

There is no INPUT so making text games in PlayBasic is quite a bit more difficult than with more traditional BASIC dialects. However, Print is useful for creating simple examples and debugging your games.

Examples

Display a Text Message

Displaying a simple text message with Print is easy.

Print "Hello World."
Sync
WaitKey
End

Displaying Numbers

Print can display integers and floating point numbers as well as strings.

Print 3
Print 3.44
Sync
WaitKey
End

Displaying Numbers and Strings

If you want to display numbers and strings on the same line, you need to first convert the numbers to strings with str$

Print "   Number 3 : " + str$(3)
Print "Number 3.44 : " + str$(3.44)
Sync
WaitKey
End

Simple Debugging with Print

Print is useful to show the values of your game variables during runtime and therefore useful for simple debugging.

x# = 400
y# = 300

Do

    If UpKey() Then y# = y# - 1
    If DownKey() Then y# = y# + 1
    If LeftKey() Then x# = x# - 1
    If RightKey() Then x# = x# + 1

    Cls 0
        Print "x# : " + str$(x#)
        Print "y# : " + str$(y#)

        Dot x#, y#
    Sync
Loop
End

Common Mistakes

  • Forgot Sync : Anything displayed with Print will not be seen until you use Sync.
  • Forgot WaitKey : In simple examples without a game loop, WaitKey is necessary to stop the game so the message displayed by Print can be seen.

Related Pages

Cursor Position

The functions below change the location of where Print displays a message.

Other Simple Output

  • Text - display a message using x and y coordinates.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.