SYS_ListRead Function

Action

Reads a list from a file on a target machine into a list variable.

Syntax

SYS_ListRead (lsList, sFileName, ftType)
Variable Description
lsList A variable to hold the new list. LIST OF STRING.
sFileName The name (and path, if necessary) of the file containing the data. STRING.
ftType Specifies the format of the text file to be created. Only has an effect when creating a new file. One of FT_ANSI, FT_UNICODE, or FT_UTF8. Default is FT_ANSI.

Notes

SYS_ListRead is executed by the Agent process, not the Silk Test Classic process; but it is essentially the same as ListRead. To affect the host process, use the function with the hHost notation or machine handle operator. For more information about the machine handle operator and hHost, see Machine handle operator.

Each line in sFileName becomes an item in lsList. SYS_ListRead interprets all lines in sFileName as strings. Each line of sFileName is returned as a string; no other type of data is returned.

SYS_ListRead modifies the lsList variable. Any previous value in lsList is discarded.

Each item in the list can be a maximum of 512 characters. Silk Test Classic raises the exception E_FILE if sFileName is not found or cannot be opened.

SYS_ListRead is the same as SYS_GetFileContents. The basic difference is that SYS_ListRead reads and transfers information one line at a time from the Agent, while SYS_GetFileContents transfers the whole file at once. If your network has difficulty with large data packets, use SYS_ListRead rather than SYS_GetFileContents.

You can use this function in an environment that uses the Open Agent or Classic Agent. Silk Test Classic automatically uses the appropriate Agent.

Example

LIST OF STRING lsFruit
SYS_ListWrite ( { "apples", "oranges" }, "fruit.txt" , FT_ANSI )
SYS_ListRead (lsFruit, "fruit.txt" )
ListPrint (lsFruit)

//Results
//apples 
//oranges