[futurebasic] Re: [FB] Containers and memory

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2002 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Mon, 25 Mar 2002 09:16:35 +0100
David Cottrell wrote:
> Alain's reply here led me to another related issue what happens if I set
> the handle size in advance and then add something to the container?
> I have found adding to containers is quite slow and I assume it is the
> "growing" part which is slow. If I could set the container size to some
> large arbitrary size first and then fill it it should be faster. Of
> course maybe the added string would still end up being put on the end of
> an otherwise empty block of memory.
I would say in that case, you should better work with a regular
handle if you need to do that.
Here is an example that sets the size of a container in advance:

Begin Globals
Dim gC As Container
End Globals

Dim As Str255 string
Dim As Long   strLen,i

string = "ABC"
strLen = Len(string)
gC     = string // initialize the handle

SetHandleSize([@gC],10*strLen) // will hold 10 times "ABC"

For i = 0 To 9 // fill the container
Blockmove @string[1],[[@gC]]+(i*strLen),strLen

print gC

Until Fn Button


                 Program different

                      E = FB^3

FutureBASIC^3 in Europe:  http://euro.futurebasic.com/