2.11 :create()

With this method new objects can be created at runtime. The method returns the newly created object.

Definition

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

Parameters

object Parent input
This parameter defines the parent of the new object.
object Dialog := null input
This optional parameter defines to which dialog the new object shall belong.
integer Type := 3 input

This optional parameter defines whether a Default, a Model or an instance is created.

Value range

1
creates a Default
2
creates a Model
3
creates an instance

If this parameter is missing, an instance is created.

boolean Invisible := false input

This optional parameter controls, whether the new object is created invisible or with the same visibility as its Model or Default.

Value range

true
The object is always created invisible.
false
Visibility is adopted from the Model or Default.

Return value

objectId
The newly created object.
null
If the object could not be created.

Example

dialog Example

model window MWnDetail
{
  !! detail view of data sets
  .title "Detail view of data";
  rule void GetData()
  {
    !! fetching the data
    !! make window visible
    this.visible ::= true;
  }
  child pushbutton PbExit
  {
    .text "&Exit";
    on select
    {
      !! destroys the window instance
      this.window:destroy();
    }
  }
}

window WnMain
{
  .title "Data overview";
  child tablefield TfData
  {
    !! contains a data overview
    on dbselect
    {
      variable object NewObj := null;
      
      !! create visible
      !! NewObj ::= MWnDetail:create(this.dialog);
      !! create invisible
      NewObj ::= MWnDetail:create(this.dialog, true);
      NewObj:GetData();
    }
  }
}

See also

Built-in function create() in manual “Rule Language”

C function DM_CreateObject in manual “C Interface - Functions”

COBOL function DMcob_CreateObject in manual “COBOL Interface”