getShape()

Graphics objects can be addressed with this CTRL function (instead of setValue()) and attributes can be set (see also Attributes of the graphics elements). The examples of the graphics attributes are largely dealt with in accordance with this new method.

Synopsis

shape getShape(string shapeName);

shape getShape(string moduleName, string panelName, string shapeName);

shape getShape(shape panel, string shapeName);

Parameters

Parameters Description
shape Graphics object
shapeName Name of the graphics object
moduleName Name of the module
panelName Name of the panel

Return value

The function returns the graphics object or shape if OK, and otherwise a null pointer.

Error

Missing arguments, incorrect function name

Description

Using this function, graphics objects can be called in accordance with the dot convention. This defines a shape variable and writes the content of an arbitrary string to the variable.

In case of an error the function returns a null pointer which can be handled using "if( getShape("...") == 0)".

It is not possible to directly address a graphics object contained within a shape group with the notation ModuleName.PanelName:ShapeGroup.Shape. Instead the module and panel are addressed separately and the shapeName parameter is given as ShapeGroup.Shape.

The use of an empty string ("") as "shapeName" parameter will reference the shape itself. (See Example 4)

Example 1

The following example sets the contents of a plain text called "Label" + n to "Testtext"; in accordance with the dot convention.

main()
{
  int n = 1;
  shape l = getShape("Label" + n);
  l.text = "Testtext";
}

Example 2

The following example sets the contents of a plain text called Label23 to "Testtext" with the old method.

main()
{
  setValue("Label23","text","Testtext");
}

Example 3

This example addresses the rectangle "square" contained in the shapegroup "shapegroup" in the panel "testpanel" in the "TestModule" module and sets the foreCol to white.

main()
{
  shape newShape = getShape("TestModule", "testpanel", "shapegroup.square");
  newShape.foreCol("{255,255,255}");
}

Example 4

The example is started in a script belonging to the object "Elipsis1" and retrieves a shape pointer to the object itself with an empty string parameter.

main()
{
  shape s;
  s = getShape("");
  DebugTN("expected: shapePtr --> returned: ", s);
}

Assignment

Availability

UI