Variables That Stand For Characters - IBM 5110 Basic Introduction

Table of Contents

Advertisement

c
c'
A Note About Names
When you name numeric variables in BASIC, they can be:
• A single character of the extended BASIC alphabet (A-Z,
@,
$, or
#)
such as:
$, C, or V
• A single character of the extended BASIC alphabet (A-Z,
@,
$, and
#)
followed by a single number such as:
A4, $6, $3, or T3
Variables That Stand for Characters
While you usually think of variables as standing for numbers, in BASIC
you can let a variable stand for combinations of characters such as
words or names. If a variable is going to represent a word or a name,
it is called a
character variable.
You name character variables with
one letter of the extended BASIC alphabet (A-Z,
@,
$, and
#)
followed
by a dollar sign ($). The dollar sign tells the system that the variable is
a character variable.
To assign a word or name to a character variable, you enclose the
word or name in single quotation marks following the equal sign.
When character data is displayed, the single quote marks do not
appear. For example:
A$='HARVEY SMITH'
Here are the general rules:
• A character variable is named by a single letter of the extended
BASIC alphabet followed by a dollar sign ($).
• To assign a value to the character variable, enclose the words or
names you are assigning in single quotation marks following the
equal sign.
• The maximum length of a character variable is 255 characters
(default length is 18 characters).
How Your System Handles Arithmetic
29
c
c'
A Note About Names
When you name numeric variables in BASIC, they can be:
• A single character of the extended BASIC alphabet (A-Z,
@,
$, or
#)
such as:
$, C, or V
• A single character of the extended BASIC alphabet (A-Z,
@,
$, and
#)
followed by a single number such as:
A4, $6, $3, or T3
Variables That Stand for Characters
While you usually think of variables as standing for numbers, in BASIC
you can let a variable stand for combinations of characters such as
words or names. If a variable is going to represent a word or a name,
it is called a
character variable.
You name character variables with
one letter of the extended BASIC alphabet (A-Z,
@,
$, and
#)
followed
by a dollar sign ($). The dollar sign tells the system that the variable is
a character variable.
To assign a word or name to a character variable, you enclose the
word or name in single quotation marks following the equal sign.
When character data is displayed, the single quote marks do not
appear. For example:
A$='HARVEY SMITH'
Here are the general rules:
• A character variable is named by a single letter of the extended
BASIC alphabet followed by a dollar sign ($).
• To assign a value to the character variable, enclose the words or
names you are assigning in single quotation marks following the
equal sign.
• The maximum length of a character variable is 255 characters
(default length is 18 characters).
How Your System Handles Arithmetic
29

Advertisement

Table of Contents
loading

Table of Contents