Please use your browsers BACK button to return from a topic or to your previous page.

Opttech Sort 2

Windows 95/98/Me/NT/2000/XP. 2


Linux. 2

C Source Code. 2

Opttech Sort Features/Specifications. 3

Performance. 3

Sorting. 3

Record Selection. 3

Reformatting & Summing. 3

Ease of Use. 3

Input 4

Output 4

Miscellaneous. 4

How to Order 4

Opttech Sort Sample Stand-Alone and Callable Usage. 5

Using Opttech Sort with the New Graphical User Interface. 5

Using Opttech Sort Stand-Alone from the Command Line. 6

Calling Opttech Sort as a "File Sort" 5

Calling Opttech Sort as a "Record Sort" 5



Available for Windows 95/98/Me/NT/2000/XP and other operating systems.  Usable as a stand-alone utility or CALLable from your programs.  For 20 years programmers and non-programmers have relied upon Opttech Sort.  An overview of each version is given below.  All versions provide very similar facilities.

Opttech Sort has the most power and features.  If you have any questions, just call us and we will be happy to help you.



·                Our most popular version! Full range of Sorting, Selecting and other features.

·                True Windows program.  Use as a stand-alone routine or call as a subroutine (DLL).

·                Supports file sizes over 4 Gig, New Graphical User Interface, and multiple keys supported.

·                Interfaces with Visual Basic, C/C++, Delphi and more.

·                For MS-Windows  -  $249




·         Written in assembly language for high performance and ease of calling from other languages.

·         Use as a stand-alone routine (EXE) or call as a subroutine (OBJ) to many programming   languages. Many sample programs provided.

·         Unlimited file size and multiple keys supported.

·         For MS-DOS – $149




·         Full range of Sorting, Selecting and other features.

·         Use as a stand-alone routine or call as a subroutine from languages that can call a C program.

·         Unlimited file size and multiple keys supported.  Binary data as well as ASCII.

·         Requires Linux or compatible Operating System  -  $249




·         Full range of Sorting, Selecting and other features.

·         Compatible with most all C compilers and hardware platforms. i.e. SUN, HP, IBM, INTEL, MIPS, RISC etc.

·         Unlimited file size and multiple keys supported.

·         Requires C compiler (most any version will do).

·         Normally distributed on a 3½" MS-DOS formatted diskette  -  $699




Opttech Sort is the high performance Sort / Merge / Select utility.   Opttech Sort can process files of any size.  A wide variety of file types and data types are supported.  It can be used as a stand-alone command, or called as a subroutine from most programming languages.  Opttech Sort includes many advanced features (sorting, selecting, reformatting, duplicate elimination and more) to make your work easier!

Whether you need to sort 100 or 100,000,000 records (or more), Opttech Sort is the fastest, most flexible program available.  For twenty years, thousands of programmers and non-programmers rely on Opttech Sort to increase their productivity and so can you!

1.       For high performance, Opttech Sort is written in C for Windows and other operating systems and written in assembly language for DOS.

2.       Very efficient algorithms are used for sorting and Input/Output.

3.       Opttech Sort can allocate memory dynamically. This allows efficient processing when large or small amounts of memory are available. 

4.       If Opttech Sort cannot process your input data in memory it will automatically use temporary files on disk and erase them when it is done.

5.       Sample Opttech Sort timings for sorting and selecting are shown later in this information.


1.       Multiple sort fields can be specified.  Many file and data types are supported.  See Input section for more information.

1.       Records can be Included or Omitted from the output file based upon criteria you specify.

2.       Record selection provides comparisons on up to 100 fields. Operators such as, "Equal To", "Greater Than" "Contains" and, "AND"/"OR" are supported.  Conditions can be nested to any level. Example: It would be easy to select records from a mailing list file that were within a zip code range.

1.       Many facilities are available for processing records with duplicate fields.  Features include: outputting only one record of each key value; outputting all records with non-unique keys; counting duplicates and more.

2.       You can specify a starting and/or ending record number to process only part of your file.

1.       You can change the structure of the records written to the output file.  See Output section for more information.

2.       Numeric Fields can be summed on records with duplicate keys.


Opttech Sort is designed to be very easy to use!


When using Stand-Alone:

1.       Opttech Sort can be easily used directly from the GUI or  keyboard.  See below for GUI and command line samples.

2.       Filenames and control specifications can be entered on the command line to prevent prompting or saved as an Opttech Sort Control File from the GUI.

3.       Opttech Sort is easily used from within the DOS Batch Command Facility (BAT) and similar facilities or through Batch Processing Options from the GUI.

4.       Full Windows Online Help is included and additionally, information is provided when you respond to any prompt with a "?".

5.       Error messages produced by Opttech Sort are displayed in "plain English."

6.       Opttech Sort sets the DOS Errorlevel value for batch file control.

7.       A sample stand-alone session is shown later in this information.

When calling as a subroutine:

1.       Opttech Sort is invoked via a Call statement (or the equivalent). 

2.       If an error occurs, a status-code is returned to your program indicating the cause of the error.

3.       The number of records output is also returned to your program for evaluation and controls.

4.       Opttech Sort is currently callable from:*

·          BASIC - Microsoft Quick BASIC, Microsoft BASIC 6, 7, 7.1 etc., Power BASIC, Turbo Basic, Visual Basic, VB .NET.

·          C - Borland C++, Microsoft C, Microsoft Visual C++, Quick C, Turbo C, Zortech C

·          Cobol - Microfocus Cobol, Microsoft Cobol, Realia Cobol

·          FORTRAN Digital Visual Fortran, Lahey (Personal, F77L, F77L-EM32, 90)

·          PASCAL - IBM Pascal, Microsoft Pascal, Turbo Pascal for DOS and Windows.

·          OTHER - dBASE, Turbo Prolog, Assembler Language

·          *New interfaces are being developed continuously.  Please call if yours is not listed. Language availability varies by Operating System.

·          Opttech Sort is usually Called to process files, but individual records can also be passed.

Sample "file sort" and "record sort" programs are shown later in this information.





1.       Any number of records can be processed.   There is no limit imposed by Opttech Sort. The largest file you can sort is determined by your free disk space.

2.       Any number of input files can be specified.  Input files can be opened in "Shared" modes for use on network systems.

3.       Opttech Sort supports the following filetypes:

·         Text files- (ASCII, EBCDIC) fixed or variable length records with any record delimiters

·         Any fixed length record file 

·         Btrieve® files (DOS)

·         Microsoft/Microfocus Cobol files, including Indexed

·         dBASE and other database files

·         IBM and Lahey Fortran files

·         Mainframe and other variable length formats

·         Delimited fields (comma, etc.)

·         Many other file structures also supported

4.       Sort control specifications have a simple format and can be contained in a file, typed in at the keyboard or passed as a parameter.

5.       Up to 100 Sort/Merge control fields can be requested.  Control fields are specified by their starting position and length or relative field number.  They can be different data types, and Ascending or Descending sequence can be requested for each control field.

6.       Data types supported include:

·         Alpha (Lower-case sorted like Upper-case)

·         Alternate collating sequences (make your own)

·         Binary (mainframe format high-low)

·         Borland Turbo Pascal Reals

·         Character (ASCII or EBCDIC)

·         Column Binary

·         Currency

·          Date and Time (many formats)

·         Decimal Floating Point

·         IEEE Floating Point (4 or 8 byte)

·         Integer (Intel format low-high)

·         IP Address

·         Microsoft Floating Point

·         Numeric ASCII

·         Packed Decimal

·         Trailing sign ASCII

·         Zoned Decimal

7.       Full pathnames are supported.

8.       Options are available for bypassing file header data.




1.       The output file written by Opttech Sort will normally contain the "full records" that were in the input file.  Output data can be reformatted to contain a subset of your fields and other data.

2.       Data can be reformatted on output, including: repositioning fields, insertion of literal fields, record numbers, hex data, CR/LF delimiters etc.

3.       Fixed and floating point binary data can be converted to ASCII in a variety of formats.

4.       Variable length records and fields can be converted to fixed length.

5.       The order of equal key records from your input file is preserved.

6.       Sorted data can be written over input data.

7.       The number of output records is displayed on the screen or returned to your program.

1.       Opttech Sort is compatible with network systems.  Opttech Sort is supplied on a CD.

2.       Opttech Sort is not copy protected.

3.       The Sort manual consists of approximately 70 pages of clearly written material and examples.  Sample programs are included for each language.

4.       Upgrades of Opttech Sort (when available) are offered to all registered users.

5.       Excellent technical phone support is provided.  A 24-hour website (, fax and email are available.


1.       Opttech Sort may be ordered directly from Opttech by phone (775) 348-8008, email, or fax (775) 348-8009.

2.       VISA, MasterCard, AMEX, Discover, Check, Money Order, COD and Purchase Orders are accepted.   Shipped on CD. Electronic (email) version available on request.

3.       Multi-copy discounts are available.

4.       OEM and Site Licenses are available.



Opttech Sort Sample Stand-Alone and Callable Usage



Overview - Opttech Sort can be used from its Graphical User Interface (Windows version only), command line, .BAT or .CMD file, "shelled to", etc.  All you have to do is specify the Input filename, Output filename and the control specifications.

Using Opttech Sort with the New Graphical User Interface

NEW!! Graphical User Interface – A full-screen Windows interface lets you browse to select your input and output files.  Allows you to save your commonly used sorting criteria and sort with the push of a button.  Easily reference errors with complete online help documentation and how-to information.  Quickly view your input and resultant output files.  Batch Processing Options sort your files without user intervention.  


Full On-line Help corresponding to the Opttech Sort for Windows Manual is provided.



1.       Opttech Sort's prompting provides a simple command line interface.

2.       Filenames and control information can be specified on the command line to prevent prompting or browse to select in the GUI.

3.       Full Windows Online Help is included and additionally, information is provided when you respond to any prompt with a "?".

4.       Opttech Sort can be used within the DOS Batch Command facility and other similar facilities.  It sets the Errorlevel so you can check for error conditions.

5.       In the sample below your input is in Bold.



OPTTECH SORT Version 2002b

Copyright Opttech  1983-2002

Input filename(s):SAMP.DAT

Output filename:SORTED.DAT

Control filename:[Keyboard]: (enter pressed)

Enter control statement:

SORT(64,5,C,A)      <- sort parameters

Total Records Output = 50


Calling Opttech Sort as a "File Sort"

Overview - The "File Sort" capability of Opttech Sort allows you to CALL Opttech Sort from within your programs to sort files of data.  Many file types and programming languages are supported.  Program samples are provided on the Opttech Sort master CD.

1.       The sample below is a compiled Visual Basic program.  Procedures for calling from other languages are very similar.

2.       You setup the parameters to Opttech Sort (see Infilev$ =, Outfilev$ =, Ctlstmtv$ =).

3.       You invoke Opttech Sort via a CALL statement (see Call Sortvb…).

4.       The number of records output and status code are returned to you.

5.       With most languages, you link Opttech Sort with your application program via the LINK utility included with your compiler.


Private Declare Sub Sortvb Lib "OTSW32.DLL" Alias "s_1mains"(ByVal Infile$,ByVal Outfile$,ByVal Ctlstmt$,Numrec&,Retcode&)

Private Sub cmdStartButton_Click()

Infilev$ = txtInfile.Text

Outfilev$ = txtOutfile.Text

Ctlstmtv$ = txtCtlstmt.Text

Call Sortvb(Infilev$, Outfilev$, Ctlstmtv$, Numrecv&, Retcodev&)

txtNumrec.Text = Str$(Numrecv&)

txtRetcode.Text = Str$(Retcodev&)

End Sub


Overview - The "Record Sort" feature allows you to pass records (areas of memory) to Opttech Sort.  Any number of records can be passed.  When you are done passing records to Opttech Sort you change the function code and request the records back.  They come back to your program in the sorted order.


1.       The sample shown here is a partial program in the C language.  Other languages are similar.  Samples are provided on the Opttech Sort master diskette(s).

2.       You do not need to write any compare routines or other complicated coding.

3.       If the data that you pass to Opttech Sort can be held in memory, no disk access is required. 

4.       If the data that you pass to Opttech Sort is too large to be held in memory, disk workspace is used and automatically erased upon completion.

5.       An "Abort" function is provided so you can smoothly exit from the middle of a "Record Sort" process.

6.       The "Record Sort" function is provided to give you flexibility in the ways you can utilize Opttech Sort.


 /* C program calling Opttech Sort with records */

    char io_area[100], *result;

    unsigned int func, io_len, ret_code;

    FILE *f1, *fopen();

/* set up for initialization call func=1 */

    func = 1;                                       


    io_len = strlen(io_area);

    s_1raat(func, io_area, &io_len, &ret_code);

    if (ret_code != 0) sorterr(ret_code);

    if ((f1 = fopen("samp.dat","r")) == NULL) {

       printf("can not open file \n");  exit(1); }

/* pass records to sort func=2 */

    func = 2;

    result = fgets(io_area, 100, f1);

    while(result != NULL) {

       io_len = strlen(io_area);

       S_1raat(func, io_area, &io_len, &ret_code);

       if (ret_code != 0) sorterr(ret_code);

       result = fgets(io_area, 100, f1);


/* get sorted records back from sort func=3 */

    func = 3;

    while(ret_code != 1) {

       s_1raat(func, io_area, &io_len, &ret_code);

       if (ret_code == 1) break;

       if (ret_code > 1) sorterr(ret_code);

       io_area[io_len-1] = '\0';