The following program enables you to sort the existing binary file "c:\sortin" of which the record length is 100 bytes in ascending order to make the external decimal number in 4 bytes from the 20th byte as a key field. It is an example of describing the code to output the record that was firstly input if 2 or more records that have the key field with the same value exist, and output the result to the binary file "c:\sortout".
Private Sub Command1_Click()
'Specify not to display the error message.
PowerBSORT1.DispMessage = False
'The sort processing is specified.
PowerBSORT1.DisposalNumber = 0
'Specify to sort the external decimal number in 4 bytes from the
'20th byte of the record in ascending order as a key field
PowerBSORT1.KeyCmdStr = "19.4zdla"
'If the specified key fields have the same contents, it is
'specified to output the record that was formerly input first.
PowerBSORT1.HandlingSameKey = 1
'The input file name is specified.
PowerBSORT1.InputFiles = "c:\sortin"
'Binary fixed length is specified for each input file type.
PowerBSORT1.InputFileType = 1
'The output file name is specified.
PowerBSORT1.OutputFile = "c:\sortout"
'Binary fixed length is specified for each output file type.
PowerBSORT1.OutputFileType = 1
'The length of the record is 100 bytes.
PowerBSORT1.MaxRecordLength = 100
'The processing is executed.
PowerBSORT1.Action
'Processing for when an error is found.
if PowerBSORT1.ErrorCode <> 0 Then
Msgbox "An error was found in PowerBSORT." & " ErrorDetail=" & PowerBSORT1.ErrorDetail
Exit Sub
End If
End Sub