ALLOC_BUFFER

Concept Link IconSee also

Allocates a memory area of N bytes.

WebVue support - Yes.

Syntax

LongVal = ALLOC_BUFFER(N);

Return type: LONG.

Execution

The return value points to the start of the allocated block and is used subsequently for referencing the reserved memory area.

Changing the maximum size for buffer allocation with

The maximum size of a buffer allocated with ALLOC_BUFFER can be changed from its default by adding the following lines to the configuration file UICONF.DAT found in the project's C folder.

[ScadaBasic\Alloc_Buffer]

MaxSize = 10

This setting is in Mb, it is preset upon project creation to 10 Mb and the maximum permitted is 100 Mb. If absent or set to 0, then ALLOC-BUFFER cannot allocate a buffer larger than 128 Kb.

If you are allocating large memory buffers, you must pay particular attention to de-allocating the memory buffer after it has been used.

Example

This example allocates a memory area of 50 bytes.

SUB Main()

DIM hbuffer As Long;

DIM intvalue As Integer;

intvalue = 50;

 

hbuffer = ALLOC_BUFFER(intvalue);

PRINT("Buffer handle = ",hbuffer);

 

'After using the memory area created with ALLOC_BUFFER,

'always release the memory area

FREE_BUFFER(hbuffer);

END SUB