Microsoft KB Archive/21463

Sorting Pascal Binary File Containing Lstrings (Example) PSS ID Number: Q21463 Article last modified on 06-14-1988 PSS database name: B_SORT

1.00 1.01

MS-DOS

Summary: The following is an example of how to sort a Microsoft Pascal binary file:


 * 1) Use the following program to create the binary file in Pascal:

program test(input,output); var f: fileof lstring(9); begin assign(f,‘junk.dat’); f.mode:=direct; rewrite(f); f^=‘hello’; put(f); f^:=‘abcedfg’; put(f); close(f); end.

Please note that each binary record begins with one length-attribute byte (i.e., 1 length byte + 9 lstring = 10). If length byte+lstring length is an odd number, a null byte is added at the end of record.

 Type the following into a TEST.SRT file:

INPUT “JUNK.DAT” BINARY LENGTH 10 COUNT 2 FIELD STNG IS [1:10,LSTRING] KEY IS STNG OUTPUT “JUNK.OUT”

 Run the TEST.SRT program with the {sortm test} command.

Copyright Microsoft Corporation 1988.