<<

Contents

Search

>>

 

SORT_FILE

 

 

Function

 

 

Syntax:

SORT_FILE(<Input File>, <Output File>, <Ascending/Descending>, <Upper/Lower Case>, <From Line>, <Position> [,<Separator> , [<Memory> , [<Macroname>]]])

 

<Input File>

= <STRING-VARIABLE>

<Output File>

= <STRING-EXPRESSION>

<Ascending/Descending>

= <NUM-EXPRESSION>

<Upper/Lower Case>

= <NUM-EXPRESSION>

<From Line>

= <NUM-EXPRESSION>

<Position>

= <NUM-EXPRESSION>

<Separator>

= <STRING-EXPRESSION>

<Memory>

= <NUM-EXPRESSION>

<Macroname>

= <MACRONAME>

 

 

Meaning:

SORT_FILE sorts the sequential file <Input File> and saves the sorted data records in <Output File>.

 

Each data line of <Input File> must end with a linefeed.

 

<Ascending/Descending> specifies whether the sorting order is ascending or descending. If <Ascending/Descending> > 0, the order is ascending, otherwise it is descending. 

 

<Upper/Lower Case> specifies whether small and capital letters are differentiated with sorting. If <Upper/Lower Case> = 0, there is no differentiation between small and capital letters, otherwise there is. 

 

<From Line> specifies from which line the file is sorted. The lines before <From Line> are not sorted.

 

<Position> specifies the character at which sorting starts in data records. Counting starts from 1.  <Position> < 1 is equivalent to 1.

 

If a <Separator> <> ²² is specified, the program presumes that the data record of the <Input File< are separated by a separator. In this case <Position> specifies the number of a substring (SUBSTR$) that is to be sorted.

 

<Memory> specifies the size of the program-internal sorting area. <Memory> <= 0 is equivalent to 100000. In each case <Memory> lines are read from the <Input File>, sorted and finally saved in a temporary file. Afterwards a Merge is carried out over the temporary files.

 

If a <Macroname> is specified the macro is executed every time the percentage of the work progress changes. EBUS_DATA contains the percentage of the work progress.

 

If no <Macroname> is specified the percentage of the work progress is displayed in the message line.

 

SORT_FILE returns the following results:

 

Result

Meaning

0

No error

7001

<Input File> or <Output File> is missing.

7002

<Input File> does not exist.

7003

Read or Write error. ERRORTEXT$ contains the error message..

 

Parameter:

Input File

Name of the variable of a one-dimensional String Array

Output File

Number of elements in <Array> that are to be used.

Ascending/Descending

> 0: Ascending sorting order. 

Otherwise: Descending sorting order.

Upper/Lower Case

Specifies whether small and capital letters are differentiated with sorting.

From Line

Specifies from which line the file is sorted.

Position

Specifies the position from which the elements are sorted.

Separator

If a separator <> ²² is specified, a substring is sorted in the array elements.

Memory

Specifies the size of the sorting area.

Macroname

Name of the macro which is called when the percentage of the work progress changes.

 

Sample:

H% = SORT_FILE(²Test_file.txt²,²Sort.txt²,1,0,1,3,²;²,0)

 

IF H% <> 0

THEN ERRORMES = ERRORTEXT$ + STR$(H%)

ENDIF

 

See also:

SORT_ARRAY

SUBSTR$