SPC: Your PRINT Statement Spacer

SPC: Your PRINT Statement Spacer

Need to add some breathing room to your Commodore 64 PRINT statements? Look no further than the SPC command, your trusty PRINT statement spacer! This handy function inserts a specified number of spaces within your output, allowing you to create neatly aligned columns, visually appealing displays, and even simple animations. Think of it as the indentation wizard for your C64 screen!

Syntax

PRINT SPC(<spaces>)

Where: - <spaces>: The number of spaces you want to insert (0 to 255).

Applications

The SPC command is your go-to tool for:

  • Formatting text: Align columns of data, create indented paragraphs, or add spaces between words and numbers.
  • Creating visual effects: Simulate movement by gradually shifting text across the screen or creating patterns of spaces.
  • Building user interfaces: Design menus and prompts with clear visual separation between elements.

Code Examples

1. Simple Spacing:

10 PRINT "Hello"; SPC(5); "World!" :rem Output: Hello     World!

This adds 5 spaces between "Hello" and "World!".

2. Formatting a Table:

10 PRINT "Name"; SPC(10); "Age"; SPC(10); "City"
20 PRINT "----"; SPC(10); "---"; SPC(10); "----"
30 PRINT "Alice"; SPC(9); "25"; SPC(11); "New York"
40 PRINT "Bob"; SPC(11); "32"; SPC(11); "London"

This example uses SPC to create a neatly formatted table with columns for names, ages, and cities.

3. Simple Animation:

10 FOR I=0 TO 39
20 PRINT SPC(I); "*" 
30 FOR J=1 TO 50 : NEXT J :rem Short delay
40 NEXT I

This creates a simple animation of a dot moving across the screen.

SPC in the Wild: The Commodore 64 Typewriter

Imagine you're writing a letter on your Commodore 64 using a simple text editor. The SPC command would be your space bar, allowing you to insert spaces between words and format your text for readability.

Don't let your text be cramped and cluttered! With SPC, you can easily add spacing to your output, making it more visually appealing and easier to read. It's a simple yet powerful tool that can enhance your Commodore 64 programming and give your creations a professional touch. So go ahead and space things out – your C64 will thank you!

Key Points to Remember:

  • SPC can only be used within PRINT statements.
  • If the SPC function is the last item in a PRINT statement, the automatic carriage return is suppressed, allowing you to continue printing on the same line.
  • You can combine SPC with other formatting functions like TAB to create more complex layouts.