The following program enables you to sort the existing text file "c:\sortin.txt" of which the record length is 15 bytes in ascending order to make 4 bytes from the 9th byte of the record as the key field. It is an example of describing the code to summate ASCII code in 4 bytes from the 4th byte when 2 or more records that have the key field with the same value exist, and output the result to the text file "C:\sortout.txt".
Private Sub Command1_Click()
'Specify not to display the error message.
PowerBSORT1.DispMessage = False
'The sort processing is specified.
PowerBSORT1.DisposalNumber = 0
'A field is specified in the column position.
PowerBSORT1.FieldDefinition = 1
'Specify to sort ASCII code in 4 bytes from the 9th byte in ascending order as a key field.
PowerBSORT1.KeyCmdStr = "8.4asca"
'Specify to summate ASCII code in 4 bytes from 4th byte of the record as a summation field.
PowerBSORT1.SumCmdStr = "3.4asc"
'When the specified key fields have the same contents,
'the fields of the summation key is added using the record summation option.
PowerBSORT1.HandlingSameKey = 3
'The input file name is specified.
PowerBSORT1.InputFiles = "c:\sortin.txt"
'Binary fixed length is specified for each input file type.
PowerBSORT1.InputFileType = 0
'The output file name is specified.
PowerBSORT1.OutputFile = "c:\sortout.txt"
'Binary fixed length is specified for each output file type.
PowerBSORT1.OutputFileType = 0
'The maximum record length is 15 bytes.
PowerBSORT1.MaxRecordLength = 15
'The summation 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