You are here: Core Reference > Coding > Scripting > ServerObject.FindChild

ServerObject.FindChild

The ServerObject.FindChild function allows the script to find items that are stored in Groups without having to use the full path of each item. This is useful when a script needs to locate several items that are stored within the same Group.

Syntax

ServerObject.FindChild (Name)

Description

The FindChild function is designed to allow the script to search a Group for an item in that Group. If an item with the defined name is found, a ServerObject is created within the script for that item. By using the FindChild function, you can avoid the need for using the full path names of the items in a Group.

Arguments

Name {string}.

The Name is what the FindChild function searches for in the child Group.

The function will return a ServerObject for any item that is in the child Group and has a name that matches the defined Name argument.

Returns

ServerObject

Returns a a ServerObject that represents a database item that is stored within a specific Group. The ServerObject has its own functions and properties that can then be manipulated.

Example:

A Group named 'Tanks' contains a database point named 'Tank Level'. A script is to read the value of the point and display it in a message box. The FindChild function allows the script to locate the point by name, rather than having to use the full path of the point.

  • Set objTanksGroup = Server.FindObject("Tanks")
  • Set objPointLevel = objTanksGroup.FindChild("Tank Level")
  • MsgBox "Tank Level = " &objPointLevel.Interface.CurrentValue

Where:

  • objTanksGroup is the name of the variable that stores the ServerObject that is returned by the FindObject function.
  • Server.FindObject("Tanks") instructs the script to search for the database item named "Tanks". In this example, the "Tanks" item is a Group.
  • objPointLevel is the name of the variable that stores the ServerObject that is returned by the FindChild function.
  • objTanksGroup.FindChild("Tank Level") instructs the script to search for a child item named "Tank Level" within the group that is stored by the objTanksGroup variable (in this case, the group is the "Tanks" group and is stored as a ServerObject in the objTanksGroup variable).
  • MsgBox = "Tank Level = " &objPointLevel.Interface.CurrentValue instructs the script to display a message box that contains the message "Tank Level = x" where x is the current value of the database item referenced by the ServerObject that is stored in the objPointLevel variable. In this case, x is the current value of the "Tank Level" point. The Interface property is used to access the properties of the ServerObject.

See also:

Server.FindObject

Server.RootObject

Server.ThisObject.


ClearSCADA 2015 R2