Cicode Programming Reference > Cicode Function Categories > Group Functions > GrpOpen

GrpOpen

Creates a group and returns a group handle, or gets the group handle of an existing group. After you open a group, you can use the group number in functions that use groups, for example, SetArea() and AlarmSetInfo(). You can open a group that is specified in the Groups database. You can also create groups at runtime.

When you open a group that is defined in the database, a copy of the group is made - the original group is not used. You can therefore change the values in the group without affecting other facilities that use this group.

Syntax

GrpOpen(sName, nMode)

sName

The name of the group to open.

Mode

The mode of the open:

0 - Open an existing group

1 - Create a new group

2 - Attempts to open an existing group. If the group does not exist, it will create it.

Return Value

The group handle , or -1 if the group cannot be created or opened. The group handle identifies the table where data on the associated group is stored.

Related Functions

GrpClose

Example

! Open Plantwide group defined in the database.
hGrp=GrpOpen("Plantwide",0);
! Set current user area to Plantwide.
SetArea(hGrp);
GrpClose(hGrp);
! Set area to 1...10, 20 and 25 by creating a new group.
hGrp=GrpOpen("MyGrp",1);
StrToGrp(hGrp,"1..10,20,25");
SetArea(hGrp);
GrpClose(hGrp);

See Also

Group Functions

Published June 2018