FileFixedLoad Function

Action

Reads a file in a fixed-length ASCII format into memory. Each row of the file is delimited with CR or CRLF (carriage return or carriage return + linefeed characters). After the file has been read, the whole file is accessible without further I/O. The file is read into shared memory only once at a client machine, even if it is read by multiple virtual users. Usually, you will use this function in only once in your script for each file you load for example, in a start up transaction that initializes your simulation.

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.
Note: This function assumes that a particular column has the same width in each row.

Include file

Kernel.bdh

Syntax

FileFixedLoad( out hFile         : number,
               in  sFileName     : string,
               in  sFormatString : string ): 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.
sFormatString

Specifies the format of a row in the file. For each column in one row you specify the starting position and the ending position of the column (beginning with 1 as the first position in the row). You need not to specify all columns in a row, and you can specify columns that overlap with other columns.

Syntax of the format string

Format = Startpos ".." Endpos { ";" Startpos ".." Endpos }.

Example

var
  hFile, r: number; 

dcltrans
  transaction TMain
  begin
    ...

    FileFixedLoad(hFile, "login.csv", "1..20;21..40");
  end TMain;

  transaction tra1
  begin
    r := FileGetNextRow(hFile);
    ...
  end tra1;