FileCSVLoadGlobal Function

Action

Reads a file in CSV format (comma-separated format) into memory. The function is equivalent to the FileCSVLoad function except that the pointer to the current row is maintained globally between virtual users at one machine. This means that all virtual users of the file at one machine use the same global row pointer for the current row. Therefore you can sequentially access a file from multiple virtual users.

If the file name includes a directory name, the file is opened in the specified directory. Otherwise, Silk Performer searches for the file in the directory where the test script is located, in the data directory, in the results directory and in the project directory.

If you are going to use remote agents for the load test, you should store your data files in the Data directory or in the directory where the test script is located. Note that in any case you have to add the data files to your load-testing project.
注: The values for sSeparator and sDelimiter may not be equal. The sSeparator parameter is used to separate data cells, while the sDelimiter parameter is used to encapsulate a data cell if the value used for the separator is used as data itself. If these parameters are set to the same value, the parser will fail.

Include file

Kernel.bdh

Syntax

FileCSVLoadGlobal( out hFile      :number,
                   in  sFileName  : string,
                   in  sSeparator : string optional,
                   in  sDelimiter : string optional ):boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hFile Variable receiving the file handle used to access the file
sFileName Specifies the path and file name of the file to read. If you specify a file name without path information, Silk Performer searches for the file in the user data directory specified in the Directories tab of the System Settings - Workbench dialog.
sSeparator Specifies the separator of the columns you want to use (optional). Usually the separator for CSV-formatted files is the comma (",").
sDelimiter Specifies the delimiter you want to use for identifying a separator/delimiter sign within a data field (optional). By default the delimiter is the double quotes sign (").

Sample columns

Name Nickname Address City
John Smith John ““The Tester”” “Fast Lane, 1432” Test City

Since double quotes are the delimiter, the double quotes in the Nickname need to be preceded by the delimiter itself (in this case the delimiter has the same functionality as for example a backslash has in BDL code).

The address field includes a comma, which is usually the separator. To prevent FileCSVLoad from using this comma as a separator, the value of John Smith’s address must be encompassed by the delimiter (“…”).

Sample scripts

RandomLogin.bdf