DataBasic Reference > Statements and Intrinsic Functions > R > REMOVE Statement

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

Reality V15.0 ()

REMOVE Statement (DataBasic) (m618703+remove_s.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

REMOVE Statement

Successively extracts substrings from a dynamic array.

Syntax

REMOVE variable FROM array SETTING setting-var

Syntax Elements

variable The name of a variable to which the substring is assigned.

array The dynamic array from which the substrings are extracted.

setting-var The name of a variable in which a value that corresponds to the system delimiter encountered is returned.

Operation

The REMOVE statement extracts one substring from the dynamic array each time it is executed. Extraction begins with the first substring in the array until the first system delimiter is encountered. The substring is assigned to variable, a value corresponding to the system delimiter is assigned to setting-var, and the Remove Pointer is set to the beginning of the next substring.

The important feature of the REMOVE statement, and that which separates it from a simple extract function, is the use of the Remove Pointer. This allows successive extract operations on an array without having to provide a location reference and without the program having to search the array from the beginning with each extraction.

Each time the REMOVE statement is executed with a particular dynamic array, the Remove Pointer is moved to the next system delimiter. System delimiter is here defined as a character from ASCII 249 through ASCII 255.

You can execute the REMOVE statement over again until all of the substrings in the dynamic array have been extracted.

The REMOVE statement does not alter the dynamic array in any way.

You can reset the Remove Pointer back to the beginning of the array by assigning the array to itself. For example:

ARRAY.X = ARRAY.X

The values assigned to setting-var are as follows:

Value System delimiter
0 End of array
1 SM: segment mark (255)
2 AM: attribute mark (254)
3 VM: value mark (253)
4 SVM: subvalue mark (252)
5 SB: start buffer (251)
6 250
7 249

Example 1

EQU AM TO CHAR(254)
Y="First Order]Second Order":AM:"Third Order"
REMOVE REC1 FROM Y SETTING VAL1
REMOVE REC2 FROM Y SETTING VAL2

The substring "First Order" is assigned to variable REC1. The value 3 is assigned to VAL1 (signifying the Value Mark encountered). The substring "Second Order" is assigned to variable REC2. The value 2 is assigned to VAL2 (signifying the attribute mark encountered).

The pointer is positioned at the attribute mark. A subsequent REMOVE statement would extract the substring "Third Order".

Example 2

LOOP REMOVE VAR FROM ARRAY.X SETTING VAL WHILE VAL DO
GOSUB EVAL
REPEAT
ARRAY.X=ARRAY.X

Successive substrings of ARRAY.X are assigned to VAR. The program branches to subroutine EVAL where the data is used. The program loops until the last substring has been read. VAL is assigned a value of zero and the program exits from the loop. ARRAY.X is assigned to itself placing the pointer at the beginning of the array.

RealityV15.0Comment on this topic