ccReNew

Syntax

ccReNew(pnt:INT BYREF, element_count:INT, element_size:INT), INT

Description

The function ccReNew resizes memory allocated via New().

Parameters

Return value

True if the memory is succesfull resized.
False if resizing failed.

Remarks

Example usage

ccReNew_demo.eba:
'Dynamically renew an array with Strings
'Resizes memory allocated via New().
'
'based on an example of Fletchie, http://www.pyxia.com/community/viewtopic.php?t=8024
'IBpro code, compile as console

OPENCONSOLE

INT count
POINTER mystrings

'create an array with 10 strings
count = 10
mystrings = NEW(STRING, count)
FOR n=0 TO count-1
	#mystrings[n,0] = "Position " + STR$(n)
NEXT n
'Print the content of the array
FOR n=0 TO count-1
	PRINT #mystrings[n,0]
NEXT n
PRINT ""

'We want to resize the array from 10 to 15 positions. The length of a string is 255 bytes.
IF ccReNew(mystrings, 15, 255) THEN count=15 ELSE PRINT "ReNew failed!"

' now we can access 15 positions
FOR n=10 TO count-1
	#mystrings[n,0] = "New Position " + STR$(n)
NEXT n
'Print the content of the array
FOR n=0 TO count-1
	PRINT #mystrings[n,0]
NEXT n
PRINT ""

PRINT "Press any key to quit"
DO:UNTIL INKEY$<>""

'clean up memory
DELETE mystrings

CLOSECONSOLE
END

See also

The function New() in the EBasic userguide