Recordの入れ替え

【ご質問】
RecordGridの1行目と2行目の情報を入れ替えることはできるのでしょうか?

【回答】
レコード自身を入れ替えることは困難ですが、
中身のデータ自身を入れ替えることで、レコードを入れ替えたように見せることは可能です。 

{curl 6.0,7.0,8.0 applet}
{curl-file-attributes character-encoding = “shift-jis”}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField
                “First”, caption = “first name”, domain = String
            },
            {RecordField
                “Last”, caption = “last name”, domain = String
            },
            {RecordField
                “Age”, caption = “age”, domain = int
            }
        },
        {RecordData First = “First1”, Last = “Last1”, Age = 10},
        {RecordData First = “First2”, Last = “Last2”, Age = 20},
        {RecordData First = “First3”, Last = “Last3”, Age = 30}
    }
}
{let rg:RecordGrid =
    {RecordGrid
        height = 3cm, width = 9.75cm, record-source = people
    }
}
{value
    {VBox
        rg,
        {CommandButton
            width = {make-elastic},
            label = “change”,
            {on Action do
                let record1:Record = rg.records[0]
                let record2:Record = rg.records[1]

                ||1行目のデータを保持させる
                let new-record:Record = {people.new-record}
                set new-record[“First”] = record1[“First”]
                set new-record[“Last”] = record1[“Last”]
                set new-record[“Age”] = record1[“Age”]

                ||1行目 ← 2行目
                set record1[“First”] = record2[“First”]
                set record1[“Last”] = record2[“Last”]
                set record1[“Age”] = record2[“Age”]

                ||2行目 ← 保持していたデータ
                set record2[“First”] = new-record[“First”]
                set record2[“Last”] = new-record[“Last”]
                set record2[“Age”] = new-record[“Age”]

                ||保持用レコードの削除
                {new-record.delete}
            }
        }
    }
}