www.icetips.com  Icetips Utilities Documentation 7/6/2014    

String Class:  AllocateFileString

Previous  Top  Next  


Prototype: (Long pBytesToAllocate)

 

pBytesToAllocateNumber of Bytes to allocate

 

This method is used to allocate memory for the FileString property, which is used by the ReadFileToString, WriteStringToFile and FileToString methods.  In normal operation you never need to call this method and should regard it as a PRIVATE method.  However, you can also use this method if you need a quick dynamic string.  Simply use AllocateFileString to create the string size you want and then use the FileString property as you want.  You can dispose of the string with DisposeFileString, but you don't need to call it if you want to repeatedly allocate the FileString as the AllocateFileString calls DisposeFileString before it allocates it again, so there is no risk of memory leaks.  The string is deallocated in the destructor as well.  Note that there is only one instance of the FileString active!  So calling AllocateFileStrings again will dispose of the existing string and create a new one.

 

Example:

 

ITS  ITStringClass

Code

ITS.AllocateFileString(1024)

ITS.FileString = 'This is a test'

ITS.AllocateFileString(1024)

 

At this point the FileString is an empty 1K string as the second call disposes of the first string and creates a new one.

 

See also:

FileString

ReadFileToString

WriteStringToFile

FileToString

DisposeFileString



Direct link to this page: http://www.icetips.com/manuals/utilities/allocatefilestring_stringclass.htm