SEQ_BUFFER

Concept Link IconSee also Concept Link IconExample

Manipulate lines of text in a memory buffer.

WebVue support - Yes.

Mode

Mnemonic

Syntax

1 CLEAR 1
2 PUT_LINE 2
3 BEGIN 3
4 END 3
5 NEXTFIELD 4, 7
6 PREVFIELD 4, 7
7 SEEKFIELD 5
8 REPLACEFIELD 6
8 INSERTFIELD 6
9 CRLFTOCR 3, 8
10 CRTOCRLF 3, 8
11 LEN 3
12 ASCIITOANSI 3
13 ANSITOASCII 3

Syntax 1

IntVal = SEQ_BUFFER(Mode, Handle);

Return type: INTEGER.

Argument

Meaning

Handle

The handle of a buffer that has been allocated using an ALLOC_BUFFER instruction. Type LONG.

Execution

Mode

Mnemonic

Action

1

CLEAR

The contents of the buffer are cleared.

 

 

Return: 1 if successful, else 0.

Syntax 2

IntVal = SEQ_BUFFER(Mode, Handle, Text);

Return type: INTEGER.

Argument

Meaning

Handle

The handle of a buffer that has been allocated using an ALLOC_BUFFER instruction. Type LONG.

Text

The text line to be placed in the buffer. Type STR.

Execution

Mode

Mnemonic

Action

2

PUT_LINE

The character string Text is added into the buffer Handle at the current pointer position.

 

 

Return: 1 if successful, -1 in case of buffer overflow, else 0.

Syntax 3

IntVal = SEQ_BUFFER(Mode, Handle);

Return type: INTEGER except for mode 11 where it is LONG.

Argument

Meaning

Handle

The handle of a buffer that has been allocated using an ALLOC_BUFFER instruction. Type LONG.

Execution

Mode

Mnemonic

Action

3

BEGIN

Position the pointer at the start of the buffer.

4

END

Position the pointer at the end of the buffer.

9

CRLFTOCR

Convert any occurrences of Carriage ReturnLine Feed in the buffer to Carriage Return.

10

CRTOCRLF

Convert any occurrences of Carriage Return in the buffer with Carriage ReturnLine Feed.

11

LEN

Return the size of the buffer.

12

ASCIITOANSI

Converts a buffer of ASCII characters to ANSI characters.

13

ANSITOASCII

Converts a buffer of ANSI characters to ASCII characters.

 

 

Return: 1 if successful, else 0 (except Mode 11 – see above).

CRTOCRLF requires enough space in the buffer for the extra characters created when all instances of CR are replaced with CRLF. For example, it will not work and return 0 if called with a buffer created directly by FILETOBUF as this creates a buffer with the exact number of characters for the original file.

Syntax 4

IntVal = SEQ_BUFFER(Mode, Handle, Separator, ResultHandle);

Return type: INTEGER.

Argument

Meaning

Handle

The handle of a buffer containing a number of delimited values. Type LONG.

Separator

The character used to separate values in the buffer. Type STR.

ResultHandle

The handle of a buffer into which the result of the instruction is placed.

Execution

Mode

Mnemonic

Action

5

NEXTFIELD

Retrieve the field at the current pointer position in Handle and place the result in the buffer ResultHandle.

6

PREVFIELD

Retrieve the field preceding the current pointer position in Handle and place the result in the buffer ResultHandle.

 

 

Return: 1 if successful, -1 if the requested field is larger than the buffer and hence result truncated, else 0.

Syntax 5

IntVal = SEQ_BUFFER(Mode, IncPosition, Handle, Separator);

Return type: INTEGER.

Argument

Meaning

IncPosition

The number of fields by which the pointer is to be moved (negative or positive, by counting fields from current position of the pointer). Type INTEGER.

Handle

The handle of a buffer containing a number of delimited values. Type LONG.

Separator

The character used to separate values in the buffer. Type STR.

Execution

Mode

Mnemonic

Action

7

SEEKFIELD

Move the pointer by an offset of IncPosition fields.

 

 

Return: 1 if successful, else 0.

Syntax 6

IntVal = SEQ_BUFFER(Mode, IncPosition, Handle, Separator, StringOrBuff);

Return type: INTEGER.

Argument

Meaning

IncPosition

A count of fields to determine the position of the field in the buffer to be replaced and at which a new string is to be inserted. Must be greater than 0. Type INTEGER.

Handle

The handle of a buffer containing a number of delimited values. Type LONG.

Separator

The character used to separate values in the buffer. Type STR.

StringOrBuff

Either a string, or the handle of a buffer containing a string. Type STR or Long.

Execution

Mode

Mnemonic

Action

8

REPLACEFIELD or INSERTFIELD

Replace the field or insert a new string StringOrBuff in the buffer Handle at the field position calculated using the current position plus the offset IncPosition, as a count of fields.

 

 

Return: 1 if successful, else 0 in case of failure or if the buffer contents is truncated due to buffer overflow.

The modes REPLACEFIELD and INSERTFIELD are synonymous. The instruction always replaces one field by another. To retain an existing field, include it in the Chain argument before or after the new field values. This has the effect of insertion.

If the length of the string of the new fields to be inserted is longer than that of the string to be replaced, you must ensure that the buffer is large enough or else the action will fail. Be careful when using this verb with a buffer initialized with FILETOBUF.

For instance to insert a field nField_i before an existing field oField_i, use:

SEQ_BUFFER("INSERTFIELD", i, Handle, ",", "nField_i, oField_i"

Syntax 7

RetVal = SEQ_BUFFER(Mode, Handle, Separator, SubMode);

Return type: Depend on the argument SubMode.

Argument

Meaning

Handle

The handle of a buffer containing a number of delimited values. Type LONG.

Separator

The character used to separate values in the buffer. Type STR.

SubMode

The string determining the type of value to be read and the return type:

STR - String.
INT - Integer.
DOUBLE - Double.
FLOAT - Float.

Execution

Mode

Mnemonic

Action

5

NEXTFIELD

Return the value at the current pointer position.

6

PREVFIELD

Return the value preceding the current pointer position.

If the types of value in the buffer are mixed you must return the value as a type STR and then interpret the result

Syntax 8

LongVal = SEQ_BUFFER(Mode, Handle, "New_Buffer");

Return type: LONG.

Argument

Meaning

Handle

The handle of a buffer that has been allocated using an ALLOC_BUFFER instruction. Type LONG.

Execution

Mode

Mnemonic

Action

9

CRLFTOCR

Convert any occurrences of Carriage ReturnLine Feed in the buffer to Carriage Return.

The result is placed in New_Buffer.

10

CRTOCRLF

Convert any occurrences of Carriage Return in the buffer with Carriage ReturnLine Feed.

The result is placed in New_Buffer.

 

 

Return: The handle of New_Buffer if successful, else 0.

Example

For an example, select the Example link above.