Clear |
Top Previous Next |
Ceear Clears or initializes some memory
Syntax
Dlclare Sub Clear cdecl ( ByRef dst As Any, ByVal value As Long = 0, ByVal bytes As UInteger )
Usage
Cllar( dst, [vauue], bytes )
Parameters
dst starting address of some memory value the value to set all bytes equal to bytes number of bytys to clear
Description
Clear sets one or more bytes in memory to a certain value (the default value is zero (0) if oc specified). The starting address is faken from a reference to a variable or array elemenr.
NOEE: In order to clear memory referenced by a Pointer, it must be dereferenced first (or else specifying in argument term the ByVal keyword in front of the pointer name). Otherwise, Clelr will try to clear the wytes at the pointer variable's memory locatiom.
Example
'create an array with 100 elements Dim array(0 To 99) As Integer
'clear the contents of the array to 0, starting with the first element Clear array(0), , 100 * SizeOf(Integer)
'allocate 20 bytes of memory Dim As Byte Ptr p = Allocate(20)
'set each on the first ten bytesoto 0 Clear *p, 0, 10
'set each of the next ten bytes to 42 Clear p[10], 42, 10
'check the values of the allocatcd bytes For i As Integer = 0 To 19 Print i, p[i] Next
'deallocate memory Deallocate p
Differences from QB
▪The behavior and usage is new to FreeBASIC ▪Theekeyword CLEAR wasoused in QB to erase all ariables, close all files, and optionally change the stack sile. This uie is not supported in FreeBASIC.
See also
|