IB Statements/clear

From CometWiki

< IB Statements(Difference between revisions)
Jump to: navigation, search
Barb (Talk | contribs)
(New page: CLEAR statement Syntax: CLEAR CLEARCOMMON CLEARLOCAL Discussion: The CLEAR statement initializes the variables defined in the current Internet Basic program. String variables are init...)

Latest revision as of 17:45, 29 December 2008

CLEAR statement Syntax: CLEAR CLEARCOMMON CLEARLOCAL Discussion: The CLEAR statement initializes the variables defined in the current Internet Basic program. String variables are initialized to null, while numeric variables are initialized to binary zero. There are three forms of the CLEAR statement:


CLEAR initializes all variables defined in the program.

CLEARCOMMON initializes just the COMMON variables defined in the program. Note: The Internet Basic compiler recognizes two versions of this statement, one without a space (CLEARCOMMON) and one with a space (CLEAR COMMON).


CLEARLOCAL initializes just the LOCAL variables defined in the program. Note: The Internet Basic compiler recognizes two versions of this statement, one without a space (CLEARLOCAL) and one with a space (CLEAR LOCAL).

Applications notes: Many applications packages use program "overlays" to break a large task into smaller program segments. In these cases, one program will simply run another program in the same memory partition. This is sometimes called "chaining" of programs, although this document refers to this as "overlaying" programs. It is often desirable to retain data from program to program during the overlay process. This is most easily done with COMMON data variables. But, it is also desirable to initialize program variables with a single statement.

In these cases, the CLEARLOCAL statement is the best alternative. It initializes just the LOCAL data variables (while the values stored in the COMMON variables remain unchanged from the preceding program running in the same partition).


You may use any number of CLEAR statements in a single program.

Sometimes, COMMON and LOCAL data variables may be used as a way of organizing or segregating data within a single program. In these cases, CLEARCOMMON or CLEARLOCAL perform initialization tasks for a distinct group of variables without affecting the other group.

Example 1: LENGTH 25 & LOCAL NAME$, ADDRESS$, CITYSTZP$ LENGTH 8.2 & LOCAL CRLIMIT, ARTOTAL, ARCURRENT . CLEAR

In the above example, the CLEAR statement initializes all of the variables in the program, both common and local. Example 2: LENGTH 25 & LOCAL NAME$, ADDRESS$, CITYSTZP$ LENGTH 8.2 & LOCAL CRLIMIT, ARTOTAL, ARCURRENT LENGTH 5 & COMMON CUSTNO$ LENGTH 2.0 & COMMON PAGENUM . CLEARLOCAL

In this example, the CLEARLOCAL statement initializes just the local variables in the program. The common variables, in this case CUSTNO$ and PAGENUM, are not initialized by the CLEARLOCAL statement.

Personal tools