SortActor Class

The SortActor class contains properties that enable you to specify the precedence of records in the File class. The following example shows the use of sort actors.

buttonSortFile1_click(btn: Button input) updating;
vars
    sortActor           : SortActorArray;
    sort1, sort2, sort3 : SortActor;
begin
    // Creates transient instances of SortActor and SortActorArray classes.
    create sortActor transient;
    create sort1 transient;
    create sort2 transient;
    create sort3 transient;
    // Sets the recordSize property of the file to 0, indicating the sorted
    // file has variable records.  The records will be delimited by the
    // standard carriage return and line feed endOfLine characters.
    self.file1.recordSize := 0;
    self.file1.endOfLine  := #"0D" & #"0A";
    // Sets the endOfField property to a comma, indicating the file has
    // variable fields within each record that will be delimited by a comma.
    self.file1.endOfField := ",";
    // Sets the first SortActor instance to sort using the string from the
    // 13th character of the first field through to the end of the field.
    // The sort will be done in ascending order.
    sort1.fieldNo       := 1;
    sort1.startPosition := 13;
    sort1.ascending     := true;
    // Sets the second SortActor instance to sort the duplicates from the
    // first sort using the string from the 14th character of the second
    // field through to the end of the field.  The sort will be numeric and
    // will be done in descending order.
    sort2.fieldNo       := 2;
    sort2.startPosition := 14;
    sort2.ascending     := false;
    sort2.sortType      := SortActor.SortType_Integer;
    // Sets the third SortActor instance to sort the duplicates from the
    // first and second sorts using the string from the 16th character of
    // the third field through to the end of the field.  The sort will be
    // done in ascending order.
    sort3.fieldNo       := 3;
    sort3.startPosition := 16;
    sort3.ascending     := true;
    // Adds SortActor instances to the SortActorArray for use in the sort.
    sortActor.add(sort1);
    sortActor.add(sort2);
    sortActor.add(sort3);
    // Uses the File class extractSort method to sort the file and write
    // the output to the text box.
    self.file1.extractSort(sortActor, outputFile1);
    textBox3.text := outputFile1.readString(400);
    self.resetOutputFile1;
    self.file1.close;
epilog                   // Delete the transient instances.
    delete sortActor;
    delete sort1;
    delete sort2;
    delete sort3;
end;

The SortActorArray class contains the sort actors used to sort an external file.

For details about the class constants and properties defined in the SortActor class, see "SortActor Class Constants" and "SortActor Properties", in the following subsection. For more sort actor examples, see "Example of Sorted Fixed Fields or Records" and "Example of Sorted Variable Fields or Records" under the File class extractSort method, earlier in this chapter.

Object

(None)