Spc and Tab Commands

Purpose

Affects the position of the next output in a Print statement.

Syntax

Spc(n)

Tab(n)

_Tab(n)

n:integer expression

Description

Both of these commands can only be used as part of a Print statement and not as standalone commands. When included in a Print statement, they affect the position where the next string is to be placed in slightly different ways: Spc inserts n spaces, moving the cursor that many places to the right while overwriting any characters in-between; Tab and _Tab move the cursor to the column defined by n, which means it is possible to move the cursor back before the last printed statement. (The Tab command treats the left hand column as column number 1, while _Tab treats it as column number 0 - therefore, _Tab(9) is equivalent to Tab(10).)

Example

Local a%

OpenW 1 : Win_1.FontName = "Courier" : Win_1.AutoRedraw = 1

// Prints 'HelloHelloHelloHello' starting at column 22

Print Tab(22); "HelloHelloHelloHello";

Text 1, 40, "Press a key" : KeyGet a% // Press a key

// Moves cursor back to column 27, overwrites with text...

Print Tab(27); " and Goodbye";

Text 1, 40, "And another key..." : KeyGet a% // Press a key

// ...and then uses Spc to blank out the remaining letters

Print Spc(3);

Text 1, 40, "And yet another..." : KeyGet a% // Press a key

// Inserts this text before to complete the statement

Print _Tab(9); "I shall say"

Text 1, 40, "And now close the Window"

Do : Sleep : Until Win_1 Is Nothing

Note the use of the semi-colon at the end of each statement to keep the text all on one line.

See Also

Locate, VTab, HTab

{Created by Sjouke Hamstra; Last updated: 17/05/2017 by James Gaite}