GetText Method  
 

Retrieve a text resource from the server and store it in a string buffer.

Syntax

object.GetText( Resource, Buffer )

Parameters

Resource
A string that specifies the resource on the server that will be accessed. If the resource specifies a text file, then the contents of the file will be returned to the server. If the resource specifies a script or other executable content, it will be executed and the output will be stored in the provided buffer.
Buffer
This parameter is passed by reference and specifies the string buffer which will contain the text returned by the server. This parameter must be a String or Variant type which will reference a string when the method returns. This method will not accept a byte array as an argument.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The GetText method is used to download a text file or retrieve the text output from a script and store the contents in a string buffer. Because binary data can include embedded null characters which would truncate the string, this method should only be used with text files or script output which is known to be textual. For example, it is safe to use this method when the server returns HTML or XML data, but should not be used if it returns an image or executable file. Always use the GetData method if you wish to retrieve binary data and store it in a byte array.

The text returned by the server is automatically converted to Unicode using the code page specified by the CodePage property. Text returned by a web server will typically use UTF-8 encoding, however some servers may return text content using their own locale. If you specify an incorrect code page, this can result in a conversion error.

This method will always attempt to normalize the end-of-line character sequence to use a carriage-return and linefeed (CRLF) pair. This can potentially result in a discrepancy between the size of a text file on the server and the actual length of the string buffer.

This method will attempt to indicate to the server that only textual data is acceptable, however some servers may ignore this constraint. If the server does return binary data in response to the request, the string buffer may be empty or contain unprintable characters as the result of attempting to convert the data to Unicode.

This method will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

See Also

CodePage Property, GetData Method, GetFile Method, PostData Method, PutData Method, PutFile Method, OnProgress Event