AttributeGetString Function

Action

Retrieves a string from a specified attribute of the user.

User attributes are useful when working with Silk Performer frameworks, in fact, when the user behavior is defined in two separate scripts. In that case, user attributes enable the exchange of data between scripts, for example, between a Silk Performer and a Java script.

Another useful scenario is to define project attributes in Silk Performer. Using AttributeGet(Bool, Double, Int, String), these values can be retrieved by the BDL script in order to parameterize the script via project attributes.

Include file

Kernel.bdh

Syntax

AttributeGetString( in  sName           : string,
                    out sString         : string,
                    in  nSize           : number optional,
                    in  useDefaultValue : boolean optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sName Name of the attribute of which the value is retrieved. The name of the attribute is case sensitive.
sString Buffer receiving the string.
nSize Size of the buffer that receives the string (optional). If not specified, this parameter is set to 0 (zero), indicating that the size of the string is unlimited.
useDefaultValue If set to true, the default value of a project attribute is read if no value has been defined. If not specified, this parameter is set to false.

Example

dcltrans
  transaction TMain
  var
    i                      : number;
    sUrl, sString, sBuffer : string;
  begin
    AttributeSetString("name", "Jim");
    AttributeSetInt("age", 23);
    AttributeSetDouble("cash", 4503.60);
    AttributeSetBinary("code", "\h9EF30533");

    // do anything, for example, call an external function 

    for i := 1 to AttributeGetInt("TIMES") do
      AttributeGetString("URL", sUrl);
      WebPageUrl(sUrl);
    end;

    AttributeGetString("name", sString);
    writeln(sString);
    writeln(AttributeGetInt("age"));
    writeln(AttributeGetDouble("cash"));
    AttributeGetBinary("code", sBuffer);
    WriteData(sBuffer, STRING_COMPLETE);
  end TMain;