www.icetips.com  Icetips Utilities Documentation 8/22/2014    

String Class:  WriteStringToFile

Previous  Top  Next  


Prototype: (String pFileName, String pContent, Byte pAppend=False),Long,PROC

 

pFileNameName of file to write the string to
pContentContent to write to the file
pAppendIf pAppend is true, the file is opened or created if it doesn't exist.  If it is false, the file is always created.

 

ReturnsReturns the number of bytes written to the file

 

This method writes the passed string to the specified file.  The content can be anything, but would normally be written to a text file, although there is nothing preventing this from being used with binary data files.  You can specify if the file should be overwritten or if it should be appended to.  With pAppend=False, the file will always be created, even if it exists.  With pAppend=True, the file will be written to but never overwritten.  If the file doesn't exist it will be created when pAppend=True.  This method uses the AllocateFileString to allocate memory for the contents and by doing so re-allocates the FileString.  Because of that you need to make sure that you do not have important data in the FileString property before you call this method.

 

Example:

ITS  ITStringClass

S    String(1024)

Code

S = 'Icetips Alta LLC<13,10>' &|

    '3430 E Highway 101 Ste 28<13,10>' &|

    'Port Angeles, WA 98362<13,10>'

ITS.WriteStringToFile('C:\Temp\Test.txt')

 

This will write the contents of the string to a file called C:\Temp\Test.txt and it will now contain this:

 

Icetips Alta LLC

3430 E Highway 101 Ste 28

Port Angeles, WA 98362

 

See also:

FileString

ReadFileToString

WriteQToFile

AllocateFileString

DisposeFileString



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