WriteData Function

Action

Writes a specified number of bytes to a new line of the output file (.wrt) of the virtual user. This function can be used to write binary data in a readable notation.

Note: Output files (.wrt) are generated only if the generation of these files is enabled in the General tab of the Profile Settings - Results dialog.

Include file

Kernel.bdh

Syntax

WriteData( in sData    : string,
           in nDataLen : number optional,
           in nOption  : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sData String buffer containing the data to write to the output file.
nDataLen Number of bytes to be written to the output file (optional).
nOption

Specifies the format used for writing (optional). Can be one of the following:

  • OPT_WRITEDATA_PRINTABLE (default). If the string buffer contains only printable characters, the ASCII representation of the data is printed. Otherwise, a mixed notation is used

  • OPT_WRITEDATA_HEX. A mixed notation is used for writing

  • OPT_WRITEDATA_HEXONLY. The data is printed in hexadecimal notation

Example

transaction TMain
  var
    s1: string;
  begin
    SetMem(s1, 1, "\h20212223243040414243444546" "Micro Focus Software Corporation", 27);
    write("Default: <");
    WriteData(s1);
    writeln(">");
    write("OPT_WRITEDATA_PRINTABLE: <");
    WriteData(s1, STRING_COMPLETE, OPT_WRITEDATA_PRINTABLE);
    writeln(">");
    write("OPT_WRITEDATA_HEX: <");
    WriteData(s1, STRING_COMPLETE, OPT_WRITEDATA_HEX);
    writeln(">");
    write("OPT_WRITEDATA_HEXONLY: <");
    WriteData(s1, STRING_COMPLETE, OPT_WRITEDATA_HEXONLY);
    writeln(">");
  end TMain;