11.8 create()

New objects can be created in the IDM during runtime with the function create(). The function returns the new generated object as result.

Definition

object create
(
      object  Class  input,
      object  Parent input
  { , object  Dialog input }
  { , integer Type   := 3 input }
  { , boolean CreateInvisible := false input }
)

Parameters

object Class input
This parameter indicates the object from which a new instance is to be created. Thus, the object may be a default or a model.
object Parent input
This parameter indicates the object parent.
object Dialog input
The optional parameter indicates the dialog to which the object is to belong.
integer Type := 3 input

This parameter (optional) indicates whether a default, a model or an object is to be created:

1
Default
2
Model
3
object

If this parameter is not declared, an object will be generated automatically.

boolean CreateInvisible := false input

With this optional parameter you can define whether the object is to be created invisibly or as it was defined in the model.

true
The object is always created invisibly.
false
The visibility is taken from the model or default.

Return value

objectId
Identifier of the newly created object.
null
Null-ID - since the object could not be created.

Example

dialog CREATE

variable object OBJ_Create := null;
variable integer Y := 50;

default window
{
}

default pushbutton
{
}

window W1
{
  .title "creating objects";
  .visible true;

  child pushbutton DO_create;
  {
    .xleft 10;
    .ytop 10;
    .text "create";
  }
}

on DO_create select
{
  !! Creating object and specifying it as child of W1
  OBJ_Create := create (pushbutton, W1);
  !! Checking if the object has been created
  if OBJ_Create <> null then
    !! Setting coordinates
    OBJ_Create.ytop := Y;
    Y := Y + 30;
  endif
}

See also

Method :create()

C function DM_CreateObject in manual “C Interface - Functions”

COBOL function DMcob_CreateObject in manual “COBOL Interface”