2.27 :move()

There are two different forms of the :move() method:

2.27.1 :move() (List Objects)

This method moves rows and columns to another position within the contents of an object whose contents consist of multiple entries indexed with integer or index. Along with the contents, the associated attributes are moved accordingly.

Definition

void :move
(
      integer Position input,
      integer Target input
  { , integer Count := 1 input }
  { , boolean Direction := false input }
)

Parameters

integer Position input
This parameter defines the first row or column to be moved.
integer Target input
This parameter specifies where the rows or columns should be moved to.
integer Count :=1 input
This optional parameter defines the number of rows or columns that are moved. If the parameter is not specified, 1 is taken as default.
boolean Direction := false input

This optional parameter controls whether rows or columns are moved in the tablefield. This depends on the value of the tablefield attribute .direction.

The parameter may only be passed for the tablefield. For other objects than the tablefield, passing the parameter will result in an error.

Value range

false
Moves against the direction given in the .direction attribute
true
Moves in the same direction as given in the .direction attribute

Thus these contents are moved in the tablefield:

Parameter Direction

.direction 1 (vertical)

.direction 2 (horizontal)

false

row(s)

column(s)

true

column(s)

row(s)

Return value

None.

If an error has occurred when moving, the method will return a fail.

Objects with this method

Example

dialog MethodMove

model pushbutton MPb {
  .xleft 216;
  .width 72;
  .sensitive false;
  .datamodel Lb;
  .dataget[.sensitive] .activeitem;
  integer Direction ::= 0;
  boolean Max ::= false;

  on select {
    this.datamodel:MoveItem(this.Direction, this.Max);
  }
}

model MPb MPbUp {
  .Direction ::= -1;
  :represent() {
    case Attribute
      in .sensitive:
        Value := (Value > 1);
        pass this:super();
      otherwise:
        // Handle other attributes
    endcase
  }
}

model MPb MPbDown {
  .Direction ::= 1;
  :represent() {
    case Attribute
      in .sensitive:
        Value := (Value > 0 and Value < this.datamodel[.sensitive].itemcount);
        pass this:super();
      otherwise:
        // Handle other attributes
    endcase
  }
}

window Wn {
  .width 320;
  .height 240;
  .title "IDM Example: Method :move()";

  on close { exit(); }

  statictext St {
    .xleft 12;
    .ytop 12;
    .sensitive false;
    .text "Select an item and move it with the buttons";
  }

  listbox Lb {
    .xleft 12;
    .width 180;
    .yauto 0;
    .ytop 36;
    .ybottom 12;
    .selstyle single;
    .activeitem 0;
    .content[1] "Rome";
    .content[2] "Stockholm";
    .content[3] "Madrid";
    .content[4] "London";
    .content[5] "Oslo";
    .content[6] "Berlin";
    .content[7] "Paris";
    .content[8] "Lisbon";
    .content[9] "Helsinki";

    on select {
      this:propagate();
    }

    rule void MoveItem(integer Direction, boolean Max) {
      if Max then
        if Direction = -1 then
          this:move(this.activeitem, 1, 1);
        endif
        if Direction = 1 then
          this:move(this.activeitem, this.itemcount, 1);
        endif
      else
        this:move(this.activeitem, this.activeitem + Direction, 1);
      endif
      this:propagate();
    }
  }

  MPbUp PbFirst {
    .ytop 36;
    .text "First";
    .Max ::= true;
  }
  MPbUp PbUp {
    .ytop 72;
    .text "Up";
  }
  MPbDown PbDown {
    .ytop 108;
    .text "Down";
  }
  MPbDown PbLast {
    .ytop 144;
    .text "Last";
    .Max ::= true;
  }
}

2.27.2 :move() (Arrays)

This method moves items of an array (indexed, non-associative, user-defined attribute) to another position in the array.

Definition

void :move
(
  attribute Attr input,
  integer Position input,
  integer Target input,
  integer Count input
)

Parameters

attribute Attr input
This parameter defines the user-defined attribute on which the method should be applied.
integer Position input
This parameter specifies the index of the first item to be moved.
integer Target input
This parameter determines where the items should be moved to.
integer Count input
This parameter defines how many items are moved.

Return value

None.

If an error has occurred when moving, the method will return a fail.

Objects with this method

All objects that may have user-defined attributes.

See also

Chapter “Methods for Arrays of User-defined Attributes” in manual “User-defined Attributes and Methods”