USERNAME

The USERNAME function returns the name of the currently logged on user.

Typically, the USERNAME function is used to allow the name of the currently logged on user to be passed as an argument to a User Method.

Function Name

USERNAME

Description

Returns the name of the user account being used by the currently logged on user.

Arguments

USERNAME()

Returns

STRING

The name of the user account being used by the currently logged on user. If the current user is not logged on, USERNAME returns GUEST (for ViewX, or for Original WebX clients). (To use a Virtual ViewX client, you need to log on via a valid user account.)

Syntax

USERNAME()

The user name can be passed as an argument to a Logic program. (A string input variable has to be included in the VAR_INPUT list).

Example:

An ST program is created to add the values of 3 points, read the user name of the user that executed the program, and write the user name and the total value of the points to a string point on the server.

The ST program has variable inputs for the 3 points and a string variable input for the user name. The string variable input will use the value that is returned by the USERNAME function.

The ST program is executed via a User Method pick action called 'Total'. The configuration of the User Method includes:

  • Object—The name of the ST program database item.
  • Method—The name of the method that is performed when the User Method is selected, and a definition of its arguments.

    In this case, the Method is Execute (USERNAME () ). This means that the User Method calls the Execute method on the ST program and passes the user's name to the ST program. The ST program then calculates the total of the 3 points and outputs the total as well as the user name that was provided by the USERNAME function. The output of the ST program is written to a string point on the server.

  • Title—This is the name of the User Method pick action, in this case, Total.

    A user logs on to the server via a user account named 'Manager'. The user selects the 'Total' User Method for the ST program. The ST program reads the name of currently logged on user ('Manager') and the values of the 3 input points. For this example, let's say the point values are 12, 45, and 81.

    The ST program calculates the total of the 3 input points and outputs the total along with the user name. The output of the ST program is written to a string point on the server. The current value of the string point is 138 Manager (total of 3 points + username).

Further Information

Working with Logic Programs in the Geo SCADA Expert Guide to Logic.


Disclaimer

Geo SCADA Expert 2019