
Chapter 5. Data Types
71
5.5 Scope of Variables
You may scope work variables and register variables to be local or global with the
PRIVATE
or
GLOBAL
statement, respectively.
(5)
Global variables
A global variable can be accessed by any routine in source files to share information
between those routines. Before access to it, you need to declare it with the
GLOBAL
statement.
(6)
Local variables
A local variable can only be accessed by any routine in a source file where it is defined.
Before access to it, you need to declare it with the
PRIVATE
statement.
(7)
Variables not declared to be global or local
If not declared to be global or local, a variable is closed in each file where it is defined.
A variable used inside the
FUNCTION
or
SUB
function without declaration is available
only within a function where it is defined.
You may also share variables between user programs when one program chains to another by
declaring variables to be common with the
COMMON
statement.
5.5.1 Global Variables
A global variable can be shared between source files in a program. In each file where you want
to use a particular global variable, write
GLOBAL
preceding a desired variable name or
DEFREG
statement.
(Example)
GLOBAL aaa%
GLOBAL bbb$[10]
GLOBAL ccc$(5,3)[30]
GLOBAL DEFREG ddd
GLOBAL DEFREG eee%(5)
(Example 1) To share the variable aa% between Files 1 and 2, define aa% by using the
GLO-
BAL
statement in each file as follows:
File 1
File 2
GLOBAL aa%
GLOBAL aa%
Before access to a global variable, you should define it.
Содержание BHT-BASIC 100 SERIES
Страница 1: ......
Страница 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Страница 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Страница 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Страница 192: ...Chapter 14 Statement Reference 184 Example OPEN master Dat AS 1 FIELD 1 20 AS bar 10 AS ky CLFILE 1 CLOSE 1...
Страница 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...
Страница 349: ...341 Run time errors Error code Meaning 05h Parameter out of the range checktype is out of the range...
Страница 383: ...375 Run time errors Reference Error code Meaning 05h Parameter out of the range Functions LEFT LEN and RIGHT...