#COMPILE EXE

OPTION EXPLICIT

#INCLUDE "win32api.inc"

'------------------------------------
#INCLUDE "COMDLG32.INC" ' OpenFile/SaveFile Dialog
GLOBAL ghInst AS LONG
GLOBAL hMainWnd AS DWORD
GLOBAL ofn AS OPENFILENAME
GLOBAL szFileName AS ASCIIZ*%MAX_PATH
GLOBAL szTitleName AS ASCIIZ*(%MAX_FNAME+%MAX_EXT)
'------------------------------------


#INCLUDE "nist_demo.inc"


FUNCTION Exist(File$) AS LONG
  LOCAL Dummy&
  Dummy& = GETATTR(File$)
  FUNCTION = (ERRCLEAR = 0)
END FUNCTION




GLOBAL hBitmap AS LONG

CALLBACK FUNCTION DlgProc() AS LONG



STATIC hButton  AS DWORD
STATIC hButton2 AS DWORD
STATIC hButton3 AS DWORD
STATIC hButton4 AS DWORD
STATIC hButton5 AS DWORD
STATIC hButton6 AS DWORD

STATIC HourGlass AS LONG


DIM a AS LONG
DIM nResult AS INTEGER

STATIC pic AS BITMAP
STATIC hDCBmp AS LONG, hDC AS LONG, hBmpOld AS LONG
LOCAL hDCPaint AS LONG
LOCAL ps AS PAINTSTRUCT
LOCAL tRect AS RECT



DIM szModuleFileName AS ASCIIZ * %MAX_PATH
DIM length AS INTEGER
STATIC programfilepath AS STRING
DIM filedirectory AS STRING
DIM filename AS STRING
DIM output_message AS STRING
DIM SIZE AS LONG
DIM nist_txt_field AS STRING
DIM type_2_number_of_records AS LONG
DIM type_3_number_of_records AS LONG
DIM type_4_number_of_records AS LONG
DIM type_5_number_of_records AS LONG
DIM type_6_number_of_records AS LONG
DIM type_7_number_of_records AS LONG
DIM type_8_number_of_records AS LONG
DIM type_9_number_of_records AS LONG
DIM type_10_number_of_records AS LONG
DIM type_13_number_of_records AS LONG
DIM type_14_number_of_records AS LONG
DIM type_15_number_of_records AS LONG
DIM type_16_number_of_records AS LONG
DIM type_17_number_of_records AS LONG
DIM type_99_number_of_records AS LONG
DIM nist_int_field AS LONG
DIM idc AS LONG
DIM idc_current AS LONG

DIM output_directory AS STRING ' trinsim

DIM nist_binary_field() AS BYTE
DIM byte_array() AS BYTE
DIM size_of_byte_array AS LONG
DIM byte_array_ptr AS BYTE PTR
DIM i AS INTEGER
DIM hBitmap AS LONG
DIM ret AS LONG
DIM file_for_opening AS INTEGER, file_for_saving AS INTEGER
DIM input_data_stream() AS BYTE
DIM lpszBuffer AS ASCIIZ PTR

DIM image_compression_code AS STRING







    SELECT CASE CBMSG
    CASE %WM_INITDIALOG

        IF hBitmap THEN
           hDC = getDC ( CBHNDL)
           IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
           hBmpOld = SelectObject( hDCBmp, hBitmap )
           GetObject hBitmap, SIZEOF( pic ), pic
        END IF





hButton  = CreateWindow("button","Create and Insert",%WS_CHILD OR %WS_VISIBLE,10,317,150,33,CBHNDL,100,ghInst,0)
hButton2 = CreateWindow("button","Read and Modify",%WS_CHILD OR %WS_VISIBLE,175,317,150,33,CBHNDL,101,ghInst,0)
hButton3 = CreateWindow("button","Read and Export",%WS_CHILD OR %WS_VISIBLE,340,317,150,33,CBHNDL,102,ghInst,0)
hButton4 = CreateWindow("button","Read Single Field",%WS_CHILD OR %WS_VISIBLE,10,360,150,33,CBHNDL,103,ghInst,0)
hButton5 = CreateWindow("button","Delete Single Field",%WS_CHILD OR %WS_VISIBLE,175,360,150,33,CBHNDL,104,ghInst,0)
hButton6 = CreateWindow("button","Register",%WS_CHILD OR %WS_VISIBLE,340,360,150,33,CBHNDL,105,ghInst,0)
'MSGBOX "CREATE"

     ' Gets full filename of the program
     GetModuleFileName BYVAL %NULL, szModuleFileName, SIZEOF(szModuleFileName)
     ' Extracts file path from full filename
     length = LEN(szModuleFileName)
     i = length
     WHILE ((ASC(szModuleFileName, i) <> ASC("\") ) AND (i > 0))
     i = i - 1
     WEND
     programfilepath = LEFT$(szModuleFileName, i)



EXIT FUNCTION


    CASE %WM_COMMAND

        SELECT CASE CBCTL
          CASE %IDCANCEL
            DIALOG END CBHNDL, 0








'====================================================================================
          CASE 100  'Create and Insert
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION


        CONTROL DISABLE CBHNDL, 100&
        CONTROL DISABLE CBHNDL, 101&
        CONTROL DISABLE CBHNDL, 102&
        CONTROL DISABLE CBHNDL, 103&
        CONTROL DISABLE CBHNDL, 104&
        CONTROL DISABLE CBHNDL, 105&
        HourGlass = 1 : MOUSEPTR 11 'HourGlass


        'Creates new empty NIST file
        CALL DWORD NISTLibrary_Param.DProcs.pCreateNewNISTFile USING CreateNewNISTFile()


'======================================================
    MSGBOX "Inserting/replacing Type-1 and Type-2 records..."

   'Type-1 record Logical record length (LEN) field is handled automatically
   'and the value of the "LEN" field cannot be changed manually.
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "LEN", "100") TO ret

   'You can modify value of Type-1 record Version number (VER) field, however please keep in mind that
   'the entry in "VER" field for ANSI/NIST-ITL 1-2000 approved standard must be "0300".
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "VER", "0300") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Type of transaction (TOT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TOT", "IMG") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Date (DAT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DAT", "20081031") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Priority (PRY)
   'The length of Priority (PRY) field must be equal to 1 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "PRY", "1") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Destination agency identifier (DAI)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DAI", "Central Police Station") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Originating agency identifier (ORI)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "ORI", "Local Police Station") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Transaction control number (TCN)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TCN", "000045321") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Transaction control reference (TCR)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TCR", "0000078901") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Native scanning resolution(NSR)
   'The length of Native scanning resolution(NSR) field must be equal to 5 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "NSR", "19.69") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Nominal transmitting resolution (NTR)
   'The length of Nominal transmitting resolution (NTR) field must be equal to 5 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "NTR", "19.69") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Domain name (DOM)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DOM", "NORAM") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Greenwich mean time (GMT)
   'The length of Greenwich mean time (GMT) field must be equal to 15 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "GMT", "20081031152345Z") TO ret


   'Modifies NIST file, inserts three Type-2 records,
   'if these records already exist then they are overwritten and replaced

   'Inserts first Type-2 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, -1, 30, "", "James Clerk") TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 31, "", "Maxwell") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 32, "", "Berlin, Germany") TO ret

   'Inserts second Type-2 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, -1, 30, "", "John Smith") TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 31, "", "Watson") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 32, "", "London, UK") TO ret

   'Inserts third Type-2 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, -1, 30, "", "Alphonse Gabriel") TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 31, "", "Al Capone") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc_current, 32, "", "New York, USA") TO ret



    'Sets input directory as "input" subdirectory of the program location
    filedirectory = programfilepath + "\input\"




    MSGBOX "Inserting/replacing Type-4 records..."

'Modifies NIST file, inserts 14 Type-4 records (inserts 14 fingerprint WSQ images).
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type4_01.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "10") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret



   filename = filedirectory + "type4_02.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "9") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_03.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "8") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_04.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "7") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_05.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "6") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_06.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "5") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_07.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "4") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret



   filename = filedirectory + "type4_08.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "3") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_09.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "2") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_10.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "1") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_11.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "14") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_12.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "13") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_13.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "12") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_14.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, -1, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "11") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret



    MSGBOX "Inserting/replacing Type-7 records..."

'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type7_01.jpg"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(7, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMT", "1") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMD", "25") TO ret
'  PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "PCN", "0000000000") TO ret
'  IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMR", "00000000000") TO ret
'  HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "VLL", "0") TO ret
'  GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "GCA", "3") TO ret

   filename = filedirectory + "type7_02.jpg"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(7, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMT", "1") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMD", "26") TO ret
'  PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "PCN", "0000000000") TO ret
'  IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMR", "00000000000") TO ret
'  HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "VLL", "0") TO ret
'  GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "GCA", "3") TO ret

   filename = filedirectory + "type7_03.jpg"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(7, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMT", "1") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMD", "21") TO ret
'  PCN value of "0000000000" was already inserted by default when creating Type-7 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "PCN", "0000000000") TO ret
'  IMR value of "00000000000" was already inserted by default when creating Type-7 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMR", "00000000000") TO ret
'  HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "VLL", "0") TO ret
'  GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "GCA", "3") TO ret


   filename = filedirectory + "type7_04.jpg"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(7, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMT", "1") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMD", "22") TO ret
'  PCN value of "0000000000" was already inserted by default when creating Type-7 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "PCN", "0000000000") TO ret
'  IMR value of "00000000000" was already inserted by default when creating Type-7 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "IMR", "00000000000") TO ret
'  HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "VLL", "0") TO ret
'  GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(7, idc_current, -1, "GCA", "3") TO ret



    MSGBOX "Inserting/replacing Type-8 records..."

'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type8_01.bin"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(8, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "SIG", "0") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "SRT", "0") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "ISR", "1") TO ret
'  HLL value (image width) needs to be set manually because input file is in uncompressed format
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "HLL", "1000") TO ret
'  VLL value (image height) needs to be set manually because input file is in uncompressed format
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "VLL", "500") TO ret


   filename = filedirectory + "type8_02.bin"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(8, -1, filename) TO idc_current

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "SIG", "1") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "SRT", "0") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "ISR", "1") TO ret
'  HLL value (image width) needs to be set manually because input file is in uncompressed format
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "HLL", "1000") TO ret
'  VLL value (image height) needs to be set manually because input file is in uncompressed format
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(8, idc_current, -1, "VLL", "500") TO ret






    MSGBOX "Inserting/replacing Type-10 records..."

'Modifies NIST file, inserts Type-10 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced


   filename = filedirectory + "type10_01.jpg"
'   filename = filedirectory + "type10_01.png"
'   filename = filedirectory + "type10_01.jp2"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(10, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT", "FACE") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "PHD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "HPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "VPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CSP", "RGB") TO ret
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, 12, "", "RGB") TO ret

   'Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "POS", "F") TO ret  'Full Face Frontal


'   filename = filedirectory + "type10_02.jpg"
   filename = filedirectory + "type10_02.png"
'   filename = filedirectory + "type10_02.jp2"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(10, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT", "FACE") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "PHD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "HPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "VPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CSP", "RGB") TO ret
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, 12, "", "RGB") TO ret

   'Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "POS", "R") TO ret  'Right Profile


'   filename = filedirectory + "type10_03.jpg"
'   filename = filedirectory + "type10_03.png"
   filename = filedirectory + "type10_03.jp2"


   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(10, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT", "FACE") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "PHD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "HPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "VPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CSP", "RGB") TO ret
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, 12, "", "RGB") TO ret

   'Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "POS", "A") TO ret  'Angled Pose



    MSGBOX "Inserting/replacing Type-13 records..."

'Modifies NIST file, inserts Type-13 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type13_01.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(13, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "IMP", "6") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "SRC", "MDNISTVIP") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Latent capture date (LCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "LCD", "19990707") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "SLC", "2") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "HPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "VPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Compression algorithm (CGA)
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "CGA" ,"WSQ20") TO ret 'NIST library inserts "WSQ20" automatically, based on filename *.wsq extension

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-13 record Finger / palm position (FGP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(13, idc_current, -1, "FGP", "8") TO ret



    MSGBOX "Inserting/replacing Type-14 records..."

'Modifies NIST file, inserts Type-14 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type14_01.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(14, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "IMP", "3") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "SRC", "MDNISTVIP") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Tenprint capture date (TCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "TCD", "19990707") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "SLC", "2") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "HPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "VPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Compression algorithm (CGA)
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "CGA" ,"WSQ20") TO ret 'NIST library inserts "WSQ20" automatically, based on filename *.wsq extension

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Finger position (FGP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "FGP", "8") TO ret



    MSGBOX "Inserting/replacing Type-15 records..."

'Modifies NIST file, inserts Type-15 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced


   filename = filedirectory + "type15_01.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(15, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "IMP", "10") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PCD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "HPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "VPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "CGA", "WSQ") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PLP", "24") TO ret



   filename = filedirectory + "type15_02.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(15, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "IMP", "10") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PCD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "HPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "VPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "CGA", "WSQ") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PLP", "25") TO ret


   filename = filedirectory + "type15_03.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(15, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "IMP", "10") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PCD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "HPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "VPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "CGA", "WSQ") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(15, idc_current, -1, "PLP", "27") TO ret



    MSGBOX "Inserting/replacing Type-16 records..."

'Modifies NIST file, inserts Type-16 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type16_01.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(16, -1, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "HPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "VPS", "500") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "CGA", "WSQ") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces Type-16 record
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(16, idc_current, -1, "CSP", "A01") TO ret

'======================================================


        'Sets output file name as "sample_new.nist" (in "output" subdirectory) TO ret
        filedirectory = programfilepath + "\output\"

        'If output directory does not exist then create output directory
         IF NOT Exist(filedirectory) THEN
         MKDIR (filedirectory)
         END IF


        filename = filedirectory + "sample_new.nist"


        'Saves NIST into the file "sample_new.nist" (in "output" subdirectory) TO ret
        CALL DWORD NISTLibrary_Param.DProcs.pWriteNISTToFile USING WriteNISTToFile(filename) TO ret

        output_message = "New NIST file was created, modified and saved as " + CHR$(10) + CHR$(13) + CHR$(34) + ".\output\sample_new.nist" + CHR$(34) + CHR$(10) + CHR$(13) + _
        "Please use " + CHR$(34) + "NIST viewer" + CHR$(34) + " to see changes in" + CHR$(10) + CHR$(13) + CHR$(34) + "sample_new.nist" + CHR$(34) + " file."
        MSGBOX output_message


        CONTROL ENABLE CBHNDL, 100&
        CONTROL ENABLE CBHNDL, 101&
        CONTROL ENABLE CBHNDL, 102&
        CONTROL ENABLE CBHNDL, 103&
        CONTROL ENABLE CBHNDL, 104&
        CONTROL ENABLE CBHNDL, 105&
'        MousePointer = vbDefault
        HourGlass = 0 : MOUSEPTR 1 'Default


'====================================================================================

          CASE 101 'Read and Modify
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION

        CONTROL DISABLE CBHNDL, 100&
        CONTROL DISABLE CBHNDL, 101&
        CONTROL DISABLE CBHNDL, 102&
        CONTROL DISABLE CBHNDL, 103&
        CONTROL DISABLE CBHNDL, 104&
        CONTROL DISABLE CBHNDL, 105&
        HourGlass = 1 : MOUSEPTR 11 'HourGlass


        'Sets input file name as "sample.nist" which located in "input" subdirectory
        filedirectory = programfilepath + "input\"
        filename = filedirectory + "sample.nist"


        IF NOT Exist(filename) THEN
            MSGBOX "Error: file .\input\sample.nist does not exist."
            RETURN
        END IF


        'Reads NIST file
        CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromFile USING ReadNISTFromFile (filename) TO ret


   'Modifies NIST file, inserts/replaces Type-1 record Type of transaction (TOT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TOT", "WSQ") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Date (DAT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DAT", "20080931") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Priority (PRY)
   'The length of Priority (PRY) field must be equal to 1 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "PRY", "2") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Destination agency identifier (DAI)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DAI", "Central Intelligence Agency") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Originating agency identifier (ORI)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "ORI", "Police Station") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Transaction control number (TCN)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TCN", "000000123") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Transaction control reference (TCR)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "TCR", "000000987") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Native scanning resolution(NSR)
   'The length of Native scanning resolution(NSR) field must be equal to 5 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "NSR", "21.33") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Nominal transmitting resolution (NTR)
   'The length of Nominal transmitting resolution (NTR) field must be equal to 5 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "NTR", "21.33") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Domain name (DOM)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "DOM", "NORAM") TO ret

   'Modifies NIST file, inserts/replaces Type-1 record Greenwich mean time (GMT)
   'The length of Greenwich mean time (GMT) field must be equal to 15 bytes
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(1, -1, -1, "GMT", "20080931170316Z") TO ret


   'Modifies NIST file, inserts two Type-2 records,
   'if these records already exist then they are overwritten and replaced
   idc = 0
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc, 30, "", "William Thompson") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(2, idc, 31, "", "Kelvin") TO ret



filedirectory = programfilepath + "\input\"


'Modifies NIST file, inserts Type-4 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type4_left_thumb.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, 7, filename) TO idc_current


   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "6") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret


   filename = filedirectory + "type4_right_thumb.wsq"
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(4, 12, filename) TO idc_current
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "IMP", "3") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP1", "1") TO ret
'  FGP2 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP2", "255") TO ret
'  FGP3 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP3", "255") TO ret
'  FGP4 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP4", "255") TO ret
'  FGP5 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP5", "255") TO ret
'  FGP6 value of "255" was already inserted by default when creating Type-4 record
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "FGP6", "255") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "ISR", "1") TO ret
'  HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "HLL", "0") TO ret
'  VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "VLL", "0") TO ret
'"NIST library" inserts GCA value "1" automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(4, idc_current, -1, "GCA", "1") TO ret



'Modifies NIST file, inserts Type-10 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type10_Charles_Luciano_frontal.jpg"


   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(10, 23, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT" ,"FACE") TO ret
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT", "SCAR") TO ret


   'Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "PHD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "HPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "VPS", "300") TO ret

'"NIST library" inserts CGA value "JPEGB" automatically when creating Type-10 record, based on filename *.jpg extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CGA", "JPEGB") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CSP", "RGB") TO ret
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, 12, "", "RGB") TO ret

   'Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "POS", "F") TO ret  'Full Face Frontal




   filename = filedirectory + "type10_Charles_Luciano_profile.jpg"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(10, 24, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "IMT", "FACE") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "PHD", "20091217") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "SLC", "1") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "HPS", "300") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "VPS", "300") TO ret

'"NIST library" inserts CGA value "PNG" automatically when creating Type-10 record, based on filename *.jp2 extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CGA", "JPG") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "CSP", "RGB") TO ret
   'CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, 12, "", "RGB") TO ret

   'Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(10, idc_current, -1, "POS", "R") TO ret  'Right Profile


'Modifies NIST file, inserts Type-14 records.
'If the record with specified IDC number already exists in *.nist file,
'then existing old record is overwritten and replaced

   filename = filedirectory + "type14_replace_01.wsq"

   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordBinaryFieldFromFile USING InsertRecordBinaryFieldFromFile(14, 27, filename) TO idc_current

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Impression type (IMP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "IMP", "0") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Source agency / ORI (SRC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "SRC", "Cognaxon") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Tenprint capture date (TCD)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "TCD", "19990923") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Scale units (SLC)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "SLC", "2") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Horizontal pixel scale (HPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "HPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Vertical pixel scale (VPS)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "VPS", "197") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Compression algorithm (CGA)
'"NIST library" inserts CGA value "WSQ20" automatically when creating Type-14 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
'   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "CGA" ,"WSQ20") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Bits per pixel (BPX)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "BPX", "8") TO ret

   'Modifies NIST file, inserts/replaces mandatory Type-14 record Finger position (FGP)
   CALL DWORD NISTLibrary_Param.DProcs.pInsertRecordTxtField USING InsertRecordTxtField(14, idc_current, -1, "FGP", "14") TO ret




        'Sets output file name as "sample_modified.nist" (in "output" subdirectory) TO ret
        filedirectory = programfilepath + "output\"
         IF NOT Exist(filedirectory) THEN
         MKDIR (filedirectory)
         END IF


        filename = filedirectory + "sample_modified.nist"

        'Saves NIST into the file "sample_modified.nist" (in "output" subdirectory) TO ret
        CALL DWORD NISTLibrary_Param.DProcs.pWriteNISTToFile USING WriteNISTToFile (filename) TO ret


        MSGBOX "NIST file " + CHR$(34) + ".\input\sample.nist" + CHR$(34) + " was read, modified" + CHR$(10) + CHR$(13) + "and saved as " + CHR$(34) + ".\output\sample_modified.nist" + CHR$(34) + CHR$(10) + CHR$(13) + _
        "Please use " + CHR$(34) + "NIST viewer" + CHR$(34) + " to see changes in" + CHR$(10) + CHR$(13) + CHR$(34) + "sample_modified.nist" + CHR$(34) + " file."


        CONTROL ENABLE CBHNDL, 100&
        CONTROL ENABLE CBHNDL, 101&
        CONTROL ENABLE CBHNDL, 102&
        CONTROL ENABLE CBHNDL, 103&
        CONTROL ENABLE CBHNDL, 104&
        CONTROL ENABLE CBHNDL, 105&
        HourGlass = 0 : MOUSEPTR 1 'Default


'====================================================================================

          CASE 102 'Read and Export
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION



            szFileName = ""

            CALL InitOpenFileDlg(CBHNDL)
            CALL ShowOpenFileDlg(CBHNDL,VARPTR(szFileName),VARPTR(szTitleName))

              IF  hBitmap < > 0  THEN
                 SelectObject hDCBmp, hBmpOld
                 DeleteDC hDCBmp
              END IF

             szFileName = TRIM$( szFileName )
            IF szFileName = "" THEN EXIT FUNCTION



        CONTROL DISABLE CBHNDL, 100&
        CONTROL DISABLE CBHNDL, 101&
        CONTROL DISABLE CBHNDL, 102&
        CONTROL DISABLE CBHNDL, 103&
        CONTROL DISABLE CBHNDL, 104&
        CONTROL DISABLE CBHNDL, 105&
        HourGlass = 1 : MOUSEPTR 11 'HourGlass


        'Sets output directory ("output" subdirectory)
        filedirectory = programfilepath + "\output\"

        'If output directory does not exist then create output directory
         IF NOT Exist(filedirectory) THEN
         MKDIR (filedirectory)
         END IF

     ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
     ' usable format. This function must be called at the beginning (one time only) before
     ' any further processing of NIST file.
'            CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromFile USING ReadNISTFromFile(szFileName)
     'Instead function ReadNISTFromFile you can use function ReadNISTFromMemory (the code bellow)
'==========================

      file_for_opening = FREEFILE
      OPEN szFileName FOR BINARY AS #file_for_opening
      size_of_byte_array = LOF(file_for_opening)
      REDIM input_data_stream(0 TO size_of_byte_array) AS BYTE
      GET #file_for_opening, 1, input_data_stream()
      CLOSE #file_for_opening

     ' Loads NIST file contents from memory and decodes NIST file data into
     ' usable format. This function must be called at the beginning (one time only) before
     ' any further processing of NIST file.
     CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromMemory USING ReadNISTFromMemory(input_data_stream(0), size_of_byte_array) TO ret

     ' Here you need to free memory resources.
     ' byte_array is no longer needed after it has been read and decoded into usable format.
     REDIM input_data_stream(0) AS BYTE
'==========================



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(1) TO ret
IF (ret = 1) THEN

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(1, 0) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(1, 0) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     ' Sets filename for saving exported data of text field from type 1 record
     filename = filedirectory + "type1.txt"

     ' Writes exported data of text field from type 1 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     MSGBOX "Type 1 record text field was exported to file .\output\type1.txt"

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(1) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(2) TO type_2_number_of_records

 ' In type 2 record there might be up to 12 fingerprint images.
 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_2_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(2, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(2, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(2, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 2 record
     filename = filedirectory + "type2_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 2 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF



    output_message = "Type 2 record text field was exported to file .\output\type2_" + STR$(idc) + ".txt"
    MSGBOX output_message

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(4) TO type_4_number_of_records

 ' In type 4 record there might be up to 14 fingerprint images.
 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_4_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(4, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(4, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(4, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 4 record
     filename = filedirectory + "type4_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 4 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(4, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(4, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 4 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "GCA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "GCA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)


     filename = filedirectory + "type4_" + STR$(idc)
     output_message = "Type-4 record text field was exported to file .\output\type4_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-4 record binary field was exported to file .\output\type4_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF



     ' Writes exported data of binary field from type 4 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(4, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 4 record text field was exported to file .\output\type4_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 4 record binary field was exported to file .\output\type4_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "High-resolution grayscale fingerprint image was extracted from type 4 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(7) TO type_7_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_7_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(7, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(7, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(7, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 7 record
     filename = filedirectory + "type7_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 7 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(7, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(7, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 7 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "GCA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "GCA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)


     filename = filedirectory + "type7_" + STR$(idc)
     output_message = "Type-7 record text field was exported to file .\output\type7_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-7 record binary field was exported to file .\output\type7_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF

     ' Writes exported data of binary field from type 7 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(7, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 7 record text field was exported to file .\output\type7_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 7 record binary field was exported to file .\output\type7_" + STR$(idc) + ".jpg" + CHR$(10) + CHR$(13) +_
                 "User-defined image was extracted from type 7 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(8) TO type_8_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_8_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(8, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(8, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(8, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 8 record
     filename = filedirectory + "type8_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 8 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(8, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(8, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 8 record
     filename = filedirectory + "type8_" + STR$(idc) + ".bin"

     ' Writes exported data of binary field from type 8 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(8, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 8 record text field was exported to file .\output\type8_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 8 record binary field was exported to file .\output\type8_" + STR$(idc) + ".bin" + CHR$(10) + CHR$(13) +_
                 "Signature image was extracted from type 8 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(9) TO type_9_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_9_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(9, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(9, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(9, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 9 record
     filename = filedirectory + "type9_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 9 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(9, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(9, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 9 record
     filename = filedirectory + "type9_" + STR$(idc) + ".wsq"

     ' Writes exported data of binary field from type 9 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(9, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 9 record text field was exported to file .\output\type9_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 9 record binary field was exported to file .\output\type9_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "Minutiae data was extracted from type 9 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(10) TO type_10_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_10_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(10, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(10, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(10, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 10 record
     filename = filedirectory + "type10_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 10 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(10, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(10, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 10 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "CGA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "CGA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)


     filename = filedirectory + "type10_" + STR$(idc)
     output_message = "Type-10 record text field was exported to file .\output\type10_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-10 record binary field was exported to file .\output\type10_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF


     ' Writes exported data of binary field from type 10 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(10, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 10 record text field was exported to file .\output\type10_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 10 record binary field was exported to file .\output\type10_" + STR$(idc) + ".jpg" + CHR$(10) + CHR$(13) +_
                 "Facial & SMT image was extracted from type 10 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(13) TO type_13_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_13_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(13, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(13, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(13, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 13 record
     filename = filedirectory + "type13_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 13 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(13, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(13, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 13 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "CGA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "CGA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)



     filename = filedirectory + "type13_" + STR$(idc)
     output_message = "Type-13 record text field was exported to file .\output\type13_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-13 record binary field was exported to file .\output\type13_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF


     ' Writes exported data of binary field from type 13 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(13, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 13 record text field was exported to file .\output\type13_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 13 record binary field was exported to file .\output\type13_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "Variable-resolution latent image was extracted from type 13 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(14) TO type_14_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_14_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(14, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(14, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(14, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 14 record
     filename = filedirectory + "type14_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 14 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(14, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(14, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 14 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "CGA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "CGA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)



     filename = filedirectory + "type14_" + STR$(idc)
     output_message = "Type-14 record text field was exported to file .\output\type14_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-14 record binary field was exported to file .\output\type14_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF


     ' Writes exported data of binary field from type 14 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(14, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 14 record text field was exported to file .\output\type14_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 14 record binary field was exported to file .\output\type14_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "Variable-resolution fingerprint image was extracted from type 14 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(15) TO type_15_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_15_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(15, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(15, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(15, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 15 record
     filename = filedirectory + "type15_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 15 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(15, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(15, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 15 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "CGA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "CGA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)


     filename = filedirectory + "type15_" + STR$(idc)
     output_message = "Type-15 record text field was exported to file .\output\type15_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-15 record binary field was exported to file .\output\type15_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF


     ' Writes exported data of binary field from type 15 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(15, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 15 record text field was exported to file .\output\type15_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 15 record binary field was exported to file .\output\type15_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "Variable-resolution palmprint image was extracted from type 15 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret
IF (ret = 1) THEN

     CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(16) TO type_16_number_of_records

 ' Reads NIST file and exports all images to separate files.
 FOR i = 1 TO type_16_number_of_records STEP 1

     CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(16, i) TO idc

     ' Returns size of text NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordExportedTxtFields USING ReadSizeOfRecordExportedTxtFields(16, idc) TO size_of_byte_array
     ' Returns contents of NIST file data field as text string (char array).
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordExportedTxtFields USING ReadRecordExportedTxtFields(16, idc) TO lpszBuffer
     nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)

     IF (size_of_byte_array <> 0) THEN

     ' Sets filename for saving exported data of text field from type 16 record
     filename = filedirectory + "type16_" + STR$(idc) + ".txt"

     ' Writes exported data of text field from type 16 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_txt_field
     CLOSE #file_for_saving

     END IF

     ' Returns size of binary NIST field.
     CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(16, idc) TO size_of_byte_array
     REDIM nist_binary_field(0 TO size_of_byte_array) AS BYTE

     ' Returns contents of NIST file binary field as byte array if successful,
     ' returns NULL otherwise.
     CALL DWORD NISTLibrary_Param.DProcs.pReadRecordBinaryField USING ReadRecordBinaryField(16, idc) TO byte_array_ptr
     CALL CopyMemory(VARPTR(nist_binary_field(0)), BYVAL byte_array_ptr, size_of_byte_array)

     IF NOT (UBOUND(nist_binary_field) = 0) THEN
     ' Sets filename for saving exported data of binary field from type 16 record
    CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "CGA") TO size_of_byte_array
    ' Returns contents of NIST file data field as text string (char array).
    CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "CGA") TO lpszBuffer
    image_compression_code = PEEK$(lpszBuffer, size_of_byte_array)



     filename = filedirectory + "type16_" + STR$(idc)
     output_message = "Type-16 record text field was exported to file .\output\type16_" + STR$(idc) + ".txt." + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) + "Type-16 record binary field was exported to file .\output\type16_" + STR$(idc)

     IF ((image_compression_code = "0") OR (image_compression_code = "NONE")) THEN
        filename = filename + ".bin"
        output_message = output_message + ".bin."
     ELSEIF ((image_compression_code = "1") OR (image_compression_code = "WSQ20") OR (image_compression_code = "WSQ")) THEN
        filename = filename + ".wsq"
        output_message = output_message + ".wsq."
     ELSEIF ((image_compression_code = "2") OR (image_compression_code = "JPEGB") OR (image_compression_code = "3") OR (image_compression_code = "JPEGL")) THEN
        filename = filename + ".jpg"
        output_message = output_message + ".jpg."
     ELSEIF ((image_compression_code = "4") OR (image_compression_code = "JP2") OR (image_compression_code = "5") OR (image_compression_code = "JP2L")) THEN
        filename = filename + ".jp2"
        output_message = output_message + ".jp2."
     ELSEIF ((image_compression_code = "6") OR (image_compression_code = "PNG")) THEN
        filename = filename + ".png"
        output_message = output_message + ".png."
     END IF


     ' Writes exported data of binary field from type 16 record to the file
     file_for_saving = FREEFILE
     OPEN filename FOR BINARY AS #file_for_saving
     PUT #file_for_saving, 1, nist_binary_field()
     CLOSE #file_for_saving

     ' Converts NIST file binary field contents into HBITMAP image.
     ' Returns image in HBITMAP format if successful, returns NULL otherwise.
      CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(16, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error loading image"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = "Type 16 record text field was exported to file .\output\type16_" + STR$(idc) + ".txt" + CHR$(10) + CHR$(13) +_
                 "Type 16 record binary field was exported to file .\output\type16_" + STR$(idc) + ".wsq" + CHR$(10) + CHR$(13) +_
                 "Variable-resolution user-defined testing image was extracted from type 16 record binary field" + CHR$(10) + CHR$(13) +_
                 "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


     END IF

 NEXT i


END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret





        CONTROL ENABLE CBHNDL, 100&
        CONTROL ENABLE CBHNDL, 101&
        CONTROL ENABLE CBHNDL, 102&
        CONTROL ENABLE CBHNDL, 103&
        CONTROL ENABLE CBHNDL, 104&
        CONTROL ENABLE CBHNDL, 105&
        HourGlass = 0 : MOUSEPTR 1 'Default


'====================================================================================
          CASE 103 'Read Single Field
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION


            szFileName = ""

            CALL InitOpenFileDlg(CBHNDL)
            CALL ShowOpenFileDlg(CBHNDL,VARPTR(szFileName),VARPTR(szTitleName))

              IF  hBitmap < > 0  THEN
                 SelectObject hDCBmp, hBmpOld
                 DeleteDC hDCBmp
              END IF

             szFileName = TRIM$( szFileName )
            IF szFileName = "" THEN EXIT FUNCTION



        CONTROL DISABLE CBHNDL, 100&
        CONTROL DISABLE CBHNDL, 101&
        CONTROL DISABLE CBHNDL, 102&
        CONTROL DISABLE CBHNDL, 103&
        CONTROL DISABLE CBHNDL, 104&
        CONTROL DISABLE CBHNDL, 105&
        HourGlass = 1 : MOUSEPTR 11 'HourGlass


     ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
     ' usable format. This function must be called at the beginning (one time only) before
     ' any further processing of NIST file.
'            CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromFile USING ReadNISTFromFile(szFileName)
     'Instead function ReadNISTFromFile you can use function ReadNISTFromMemory (the code bellow)
'==========================

      file_for_opening = FREEFILE
      OPEN szFileName FOR BINARY AS #file_for_opening
      size_of_byte_array = LOF(file_for_opening)
      REDIM input_data_stream(0 TO size_of_byte_array) AS BYTE
      GET #file_for_opening, 1, input_data_stream()
      CLOSE #file_for_opening

     ' Loads NIST file contents from memory and decodes NIST file data into
     ' usable format. This function must be called at the beginning (one time only) before
     ' any further processing of NIST file.
     CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromMemory USING ReadNISTFromMemory(input_data_stream(0), size_of_byte_array) TO ret

     ' Here you need to free memory resources.
     ' byte_array is no longer needed after it has been read and decoded into usable format.
     REDIM input_data_stream(0) AS BYTE
'==========================


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(1) TO ret
IF (ret = 1) THEN





            output_message = "Type-1 record field values were read in cycle using field number" + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13)

            FOR i = 1 TO 15
                output_message = output_message & "Type-1 record "
                'Reads Type-1 record i Field Description
                CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtFieldDescription USING ReadSizeOfRecordTxtFieldDescription(1, -1, i, "") TO size_of_byte_array
                ' Returns contents of NIST file data field as text string (char array).
                CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtFieldDescription USING ReadRecordTxtFieldDescription(1, -1, i, "") TO lpszBuffer
                nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
                output_message = output_message + nist_txt_field + " ("
                'Reads Type-1 record i Field Name
                CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtFieldName USING ReadSizeOfRecordTxtFieldName(1, -1, i) TO size_of_byte_array
                ' Returns contents of NIST file data field as text string (char array).
                CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtFieldName USING ReadRecordTxtFieldName(1, -1, i) TO lpszBuffer
                nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
                output_message = output_message + nist_txt_field + ") = "
                'Reads Type-1 record i Field Value
                CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, i, "") TO size_of_byte_array
                ' Returns contents of NIST file data field as text string (char array).
                CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, i, "") TO lpszBuffer
                nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
                output_message = output_message + nist_txt_field + CHR$(10) + CHR$(13)
            NEXT i
            MSGBOX output_message


        output_message = "Type-1 record field values were read using field names" + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13)


        'Reads Type-1 record Logical record length (LEN)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "LEN") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "LEN") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + "Type-1 record Logical record length (LEN) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Version number (VER) of the standard implemented by the software or system creating the file
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "VER") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "VER") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Version number (VER) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record File content (CNT)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "CNT") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "CNT") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record File content (CNT) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Type of transaction (TOT)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "TOT") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "TOT") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Type of transaction (TOT) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Date (DAT)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "DAT") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "DAT") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Date (DAT) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Priority RY)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "PRY") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "PRY") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Priority (PRY) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Destination agency identifier (DAI)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "DAI") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "DAI") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Destination agency identifier (DAI) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Originating agency identifier (ORI)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "ORI") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "ORI") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Originating agency identifier (ORI) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Transaction control number (TCN)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "TCN") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "TCN") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Transaction control number (TCN) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Transaction control reference (TCR)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "TCR") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "TCR") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Transaction control reference (TCR) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Native scanning resolution(NSR)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "NSR") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "NSR") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Native scanning resolution (NSR) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Nominal transmitting resolution (NTR)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "NTR") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "NTR") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Nominal transmitting resolution (NTR) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Domain name (DOM)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "DOM") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "DOM") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Domain name (DOM) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Greenwich mean time (GMT)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "GMT") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "GMT") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Greenwich mean time (GMT) = "
        output_message = output_message + nist_txt_field

        'Reads Type-1 record Directory of character sets (DCS)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(1, -1, -1, "DCS") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(1, -1, -1, "DCS") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-1 record Directory of character sets (DCS) = "
        output_message = output_message + nist_txt_field

        MSGBOX output_message

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(1) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret
IF (ret = 1) THEN

        CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(2) TO type_2_number_of_records
        output_message = "Type-2 number of records = " + STR$(type_2_number_of_records)

        MSGBOX output_message


        FOR i = 1 TO type_2_number_of_records STEP 1
            ' Returns contents of NIST file data field as text string (char array) TO ret.

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(2, i) TO idc

        'Reads Type-2 record Logical record length (LEN)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(2, idc, 1, "") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(2, idc, 1, "") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = "Type-2 record Logical record length (LEN) = "
        output_message = output_message + nist_txt_field

        'Reads Type-2 record Image designation character (IDC)
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(2, idc, 2, "") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(2, idc, 2, "") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-2 record Image designation character (IDC) = "
        output_message = output_message + nist_txt_field

        'Reads Type-2 record User-defined field #30
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(2, idc, 30, "") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(2, idc, 30, "") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-2 record User-defined field #30 = "
        output_message = output_message + nist_txt_field

        'Reads Type-2 record User-defined field #31
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(2, idc, 31, "") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(2, idc, 31, "") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-2 record User-defined field #31 = "
        output_message = output_message + nist_txt_field

        'Reads Type-2 record User-defined field #32
        CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(2, idc, 32, "") TO size_of_byte_array
        ' Returns contents of NIST file data field as text string (char array).
        CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(2, idc, 32, "") TO lpszBuffer
        nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
        output_message = output_message + CHR$(10) + CHR$(13) + "Type-2 record User-defined field #32 = "
        output_message = output_message + nist_txt_field

        MSGBOX output_message


        NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret
IF (ret = 1) THEN

        CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(4) TO type_4_number_of_records
        output_message = "Type-4 number of records = " + STR$(type_4_number_of_records)

        MSGBOX output_message


        ' In type 4 record there might be up to 14 fingerprint images.
        ' Reads NIST file and shows fingerprint images on the screen.
        FOR i = 1 TO type_4_number_of_records STEP 1
            ' Returns contents of NIST file data field as text string (char array) TO ret.

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(4, i) TO idc


            'Reads Type-4 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-4 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-4 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-4 record Impression type (IMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "IMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "IMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Impression type (IMP) = " + nist_txt_field

            'Reads Type-4 record Finger position (FGP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "FGP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Finger position (FGP) = " + nist_txt_field


            'Reads Type-4 record nown or most probable Finger position (FGP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP1") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Known or most probable Finger position (FGP1) = " + STR$(nist_int_field)

            'Reads Type-4 record Second possible Finger position (FGP2)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP2") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Second possible Finger position (FGP2) = " + STR$(nist_int_field)

            'Reads Type-4 record Third possible Finger position (FGP3)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP3") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Third possible Finger position (FGP3) = " + STR$(nist_int_field)

            'Reads Type-4 record Fourth possible Finger position (FGP4)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP4") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Fourth possible Finger position (FGP4) = " + STR$(nist_int_field)

            'Reads Type-4 record Fifth possible Finger position (FGP5)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP5") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Fifth possible Finger position (FGP5) = " + STR$(nist_int_field)

            'Reads Type-4 record Sixth possible Finger position (FGP6)
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "FGP6") TO nist_int_field
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Sixth possible Finger position (FGP6) = " + STR$(nist_int_field)


            'Reads Type-4 record Image scanning resolution (ISR)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "ISR") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "ISR") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Image scanning resolution (ISR) = " + nist_txt_field

            'Reads Type-4 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-4 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field

            'Reads Type-4 record Grayscale compression algorithm (GCA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(4, idc, -1, "GCA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(4, idc, -1, "GCA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Grayscale compression algorithm (GCA) = " + nist_txt_field

            ' Returns Type-4 record Size of binary field.
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordBinaryField USING ReadSizeOfRecordBinaryField(4, idc) TO nist_int_field

            output_message = output_message + CHR$(10) + CHR$(13) + "Type-4 (" + FORMAT$(idc) + ") record Size of binary field = " + STR$(nist_int_field)


            ' Returns contents of NIST file binary field as byte array if successful,
            ' returns NULL otherwise.
            'ReadType4RecordBinaryField(1, idc) TO nist_binary_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(4, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "High-resolution grayscale fingerprint image was extracted from Type-4 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


        NEXT i



END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(7) TO type_7_number_of_records
            output_message = "Type-7 number of records = " + STR$(type_7_number_of_records)

            MSGBOX output_message

            ' Reads NIST file and shows tenprint images images on the screen.
            FOR i = 1 TO type_7_number_of_records


            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(7, i) TO idc

            'Reads Type-7 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-7 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-7 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-7 record Image type (IMT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "IMT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "IMT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Image type (IMT) = " + nist_txt_field

            'Reads Type-7 record Image description (IMD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "IMD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "IMD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Image description (IMD) = " + nist_txt_field

            'Reads Type-7 record Pattern classification (PCN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "PCN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "PCN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Pattern classification (PCN) = " + nist_txt_field

            'Reads Type-7 record Image capture resolution (IMR)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "IMR") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "IMR") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Image capture resolution (IMR) = " + nist_txt_field

            'Reads Type-7 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-7 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field

            'Reads Type-7 record Gray-scale compression algorithm (GCA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(7, idc, -1, "GCA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(7, idc, -1, "GCA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-7 (" + FORMAT$(idc) + ") record Gray-scale compression algorithm (GCA) = " + nist_txt_field



            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(7, idc) TO hBitmap


             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "User-defined image was extracted from Type-7 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(8) TO type_8_number_of_records
            output_message = "Type-8 number of records = " + STR$(type_8_number_of_records)

            MSGBOX output_message

            ' Reads NIST file and shows tenprint images images on the screen.
            FOR i = 1 TO type_8_number_of_records


            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(8, i) TO idc

            'Reads Type-8 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-8 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-8 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-8 record Signature type (SIG)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "SIG") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "SIG") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Signature type (SIG) = " + nist_txt_field

            'Reads Type-8 record Signature representation type (SRT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "SRT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "SRT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Signature representation type (SRT) = " + nist_txt_field


            'Reads Type-8 record Image scanning resolution (ISR)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "ISR") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "ISR") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Image scanning resolution (ISR) = " + nist_txt_field

            'Reads Type-8 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-8 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(8, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(8, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-8 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field




            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(8, idc) TO hBitmap


             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Signature image was extracted from Type-8 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret







CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(9) TO type_9_number_of_records
            output_message = "Type-9 number of records = " + STR$(type_9_number_of_records)

            MSGBOX output_message


            ' Reads NIST file and shows minutiae data images on the screen.
            FOR i = 1 TO type_9_number_of_records

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(9, i) TO idc

            'Reads Type-9 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-9 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-9 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-9 record Impression type (IMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "IMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "IMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Impression type (IMP) = " + nist_txt_field

            'Reads Type-9 record Minutiae format (FMT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "FMT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "FMT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Minutiae format (FMT) = " + nist_txt_field


            'Reads Type-9 record Originating fingerprint reading system (OFR)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "OFR") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "OFR") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Originating fingerprint reading system (OFR) = " + nist_txt_field

            'Reads Type-9 record Finger position (FGP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "FGP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "FGP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Finger position (FGP) = " + nist_txt_field

            'Reads Type-9 record Fingerprint pattern classification (FPC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "FPC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "FPC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Fingerprint pattern classification (FPC) = " + nist_txt_field

            'Reads Type-9 record Core position (CRP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "CRP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "CRP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Core position (CRP) = " + nist_txt_field

            'Reads Type-9 record Delta(s) position (DLT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "DLT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "DLT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Delta(s) position (DLT) = " + nist_txt_field

            'Reads Type-9 record Number of minutiae (MIN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "MIN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "MIN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Number of minutiae (MIN) = " + nist_txt_field

            'Reads Type-9 record Number of minutiae (RDG)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "RDG") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "RDG") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Number of minutiae (RDG) = " + nist_txt_field

            'Reads Type-9 record Number of minutiae (MRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(9, idc, -1, "MRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(9, idc, -1, "MRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-9 (" + FORMAT$(idc) + ") record Number of minutiae (MRC) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(9, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Minutiae data was extracted from Type-9 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret





CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(10) TO type_10_number_of_records
            output_message = "Type-10 number of records = " + STR$(type_10_number_of_records)

            MSGBOX output_message


            ' Reads NIST file and shows facial and SMT images on the screen.
            FOR i = 1 TO type_10_number_of_records

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(10, i) TO idc


            'Reads Type-10 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-10 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-10 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-10 record Image type (IMT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "IMT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "IMT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Image type (IMT) = " + nist_txt_field

            'Reads Type-10 record Source agency / ORI (SRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Source agency / ORI (SRC) = " + nist_txt_field

            'Reads Type-10 record Photo date (PHD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "PHD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "PHD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Photo date (PHD) = " + nist_txt_field

            'Reads Type-10 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-10 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field

            'Reads Type-10 record Scale units (SLC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SLC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SLC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Scale units (SLC) = " + nist_txt_field

            'Reads Type-10 record Horizontal pixel scale (HPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "HPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "HPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Horizontal pixel scale (HPS) = " + nist_txt_field

            'Reads Type-10 record Vertical pixel scale (VPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "VPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "VPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Vertical pixel scale (VPS) = " + nist_txt_field

            'Reads Type-10 record Compression algorithm (CGA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "CGA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "CGA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Compression algorithm (CGA) = " + nist_txt_field

            'Reads Type-10 record Colorspace (CSP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "CSP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "CSP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Colorspace (CSP) = " + nist_txt_field

            'Reads Type-10 record Subject acquisition profile (SAP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SAP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SAP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject acquisition profile (SAP) = " + nist_txt_field


            'Reads Type-10 record Subject pose (POS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "POS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "POS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject pose (POS) = " + nist_txt_field

            'Reads Type-10 record Pose offset angle (POA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "POA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "POA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Pose offset angle (POA) = " + nist_txt_field

            'Reads Type-10 record Photo description (PXS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "PXS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "PXS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Photo description (PXS) = " + nist_txt_field

            'Reads Type-10 record Photo acquisition source (PAS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "PAS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "PAS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Photo acquisition source (PAS) = " + nist_txt_field

            'Reads Type-10 record Subject quality score (SQS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SQS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SQS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject quality score (SQS) = " + nist_txt_field

            'Reads Type-10 record Subject pose angles (SPA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SPA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SPA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject pose angles (SPA) = " + nist_txt_field

            'Reads Type-10 record Subject facial description (SXS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SXS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SXS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject facial description (SXS) = " + nist_txt_field

            'Reads Type-10 record Subject eye color (SEC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SEC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SEC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject eye color (SEC) = " + nist_txt_field

            'Reads Type-10 record Subject hair color (SHC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SHC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SHC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Subject hair color (SHC) = " + nist_txt_field

            'Reads Type-10 record Facial feature points (FFP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "FFP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "FFP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Facial feature points (FFP) = " + nist_txt_field

            'Reads Type-10 record Device monitoring mode (DMM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "DMM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "DMM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Device monitoring mode (DMM) = " + nist_txt_field

            'Reads Type-10 record NCIC designation code (SMT)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SMT") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SMT") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record NCIC designation code (SMT) = " + nist_txt_field

            'Reads Type-10 record SMT size (SMS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SMS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SMS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record SMT size (SMS) = " + nist_txt_field

            'Reads Type-10 record SMT descriptors (SMD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "SMD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "SMD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record SMT descriptors (SMD) = " + nist_txt_field

            'Reads Type-10 record Color (COL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(10, idc, -1, "COL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(10, idc, -1, "COL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-10 (" + FORMAT$(idc) + ") record Color (COL) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(10, idc) TO hBitmap


             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to decompress JPG input array"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Facial & SMT image was extracted from Type-10 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(13) TO type_13_number_of_records
            output_message = "Type-13 number of records = " + STR$(type_13_number_of_records)

            MSGBOX output_message

            ' Reads NIST file and shows latent images on the screen.
            FOR i = 1 TO type_13_number_of_records


            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(13, i) TO idc

            'Reads Type-13 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-13 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-13 record Image Designation Character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Image Designation Character (IDC) = " + nist_txt_field

            'Reads Type-13 record Impression Type (IMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "IMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "IMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Impression Type (IMP) = " + nist_txt_field

            'Reads Type-13 record Source agency / ORI (SRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "SRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "SRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Source agency / ORI (SRC) = " + nist_txt_field

            'Reads Type-13 record Latent capture date (LCD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "LCD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "LCD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Latent capture date (LCD) = " + nist_txt_field

            'Reads Type-13 record Latent capture date (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Latent capture date (HLL) = " + nist_txt_field

            'Reads Type-13 record Latent capture date (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Latent capture date (VLL) = " + nist_txt_field

            'Reads Type-13 record Scale units (SLC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "SLC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "SLC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Scale units (SLC) = " + nist_txt_field

            'Reads Type-13 record Horizontal pixel scale (HPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "HPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "HPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Horizontal pixel scale (HPS) = " + nist_txt_field

            'Reads Type-13 record Vertical pixel scale (VPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "VPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "VPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Vertical pixel scale (VPS) = " + nist_txt_field

            'Reads Type-13 record Compression algorithm (CGA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "CGA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "CGA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Compression algorithm (CGA) = " + nist_txt_field

            'Reads Type-13 record Bits per pixel (BPX)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "BPX") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "BPX") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Bits per pixel (BPX) = " + nist_txt_field

            'Reads Type-13 record Finger / palm position (FGP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "FGP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "FGP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Finger / palm position (FGP) = " + nist_txt_field

            'Reads Type-13 record Search position descriptors (SPD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "SPD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "SPD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Search position descriptors (SPD) = " + nist_txt_field

            'Reads Type-13 record Print position coordinates (PPC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "PPC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "PPC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Print position coordinates (PPC) = " + nist_txt_field

            'Reads Type-13 record Scanned horizontal pixel scale (SHPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "SHPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "SHPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Scanned horizontal pixel scale (SHPS) = " + nist_txt_field

            'Reads Type-13 record Scanned vertical pixel scale (SVPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "SVPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "SVPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Scanned vertical pixel scale (SVPS) = " + nist_txt_field

            'Reads Type-13 record Comment (COM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(13, idc, -1, "COM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(13, idc, -1, "COM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-13 (" + FORMAT$(idc) + ") record Comment (COM) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(13, idc) TO hBitmap


             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Variable-resolution latent image was extracted from Type-13 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(14) TO type_14_number_of_records
            output_message = "Type-14 number of records = " + STR$(type_14_number_of_records)

            MSGBOX output_message

            ' Reads NIST file and shows tenprint images images on the screen.
            FOR i = 1 TO type_14_number_of_records


            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(14, i) TO idc

            'Reads Type-14 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-14 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-14 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-14 record Impression type (IMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "IMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "IMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Impression type (IMP) = " + nist_txt_field

            'Reads Type-14 record Source agency / ORI (SRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Source agency / ORI (SRC) = " + nist_txt_field

            'Reads Type-14 record Tenprint capture date (TCD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "TCD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "TCD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Tenprint capture date (TCD) = " + nist_txt_field

            'Reads Type-14 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-14 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field

            'Reads Type-14 record Scale units (SLC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SLC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SLC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Scale units (SLC) = " + nist_txt_field

            'Reads Type-14 record Horizontal pixel scale (HPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "HPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "HPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Horizontal pixel scale (HPS) = " + nist_txt_field

            'Reads Type-14 record Vertical pixel scale (VPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "VPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "VPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Vertical pixel scale (VPS) = " + nist_txt_field

            'Reads Type-14 record Compression algorithm (CGA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "CGA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "CGA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Compression algorithm (CGA) = " + nist_txt_field

            'Reads Type-14 record Bits per pixel (BPX)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "BPX") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "BPX") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Bits per pixel (BPX) = " + nist_txt_field

            'Reads Type-14 record Finger position (FGP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "FGP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "FGP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Finger position (FGP) = " + nist_txt_field

            'Reads Type-14 record Print position descriptors (PPD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "PPD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "PPD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Print position descriptors (PPD) = " + nist_txt_field

            'Reads Type-14 record Print position coordinates (PPC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "PPC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "PPC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Print position coordinates (PPC) = " + nist_txt_field

            'Reads Type-14 record Scanned horizontal pixel scale (SHPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SHPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SHPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Scanned horizontal pixel scale (SHPS) = " + nist_txt_field

            'Reads Type-14 record Scanned vertical pixel scale (SVPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SVPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SVPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Scanned vertical pixel scale (SVPS) = " + nist_txt_field

            'Reads Type-14 record Amputated or bandaged (AMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "AMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "AMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Amputated or bandaged (AMP) = " + nist_txt_field

            'Reads Type-14 record Comment (COM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "COM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "COM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Comment (COM) = " + nist_txt_field

            'Reads Type-14 record Finger segment position(s) (SEG)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SEG") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SEG") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Finger segment position(s) (SEG) = " + nist_txt_field

            'Reads Type-14 record NIST quality metric (NQM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "NQM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "NQM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record NIST quality metric (NQM) = " + nist_txt_field

            'Reads Type-14 record Segmentation quality metric (SQM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "SQM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "SQM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Segmentation quality metric (SQM) = " + nist_txt_field

            'Reads Type-14 record Fingerprint quality metric (FQM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "FQM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "FQM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Fingerprint quality metric (FQM) = " + nist_txt_field

            'Reads Type-14 record Alternate finger segment position(s) (ASEG)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "ASEG") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "ASEG") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Alternate finger segment position(s) (ASEG) = " + nist_txt_field

            'Reads Type-14 record Device monitoring mode (DMM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(14, idc, -1, "DMM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(14, idc, -1, "DMM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-14 (" + FORMAT$(idc) + ") record Device monitoring mode (DMM) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(14, idc) TO hBitmap


             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Variable-resolution fingerprint image was extracted from Type-14 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF


            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(15) TO type_15_number_of_records
            output_message = "Type-15 number of records = " + STR$(type_15_number_of_records)

            MSGBOX output_message


            ' Reads NIST file and shows fingerprint images on the screen.
            FOR i = 1 TO type_15_number_of_records

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(15, i) TO idc

            'Reads Type-15 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-15 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-15 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field

            'Reads Type-15 record Impression type (IMP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "IMP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "IMP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Impression type (IMP) = " + nist_txt_field

            'Reads Type-15 record Source agency/ORI (SRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "SRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "SRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Source agency/ORI (SRC) = " + nist_txt_field

            'Reads Type-15 record Palmprint capture date (PCD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "PCD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "PCD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Palmprint capture date (PCD) = " + nist_txt_field

            'Reads Type-15 record Horizontal line length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Horizontal line length (HLL) = " + nist_txt_field

            'Reads Type-15 record Vertical line length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Vertical line length (VLL) = " + nist_txt_field

            'Reads Type-15 record Scale units (SLC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "SLC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "SLC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Scale units (SLC) = " + nist_txt_field

            'Reads Type-15 record Horizontal pixel scale (HPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "HPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "HPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Horizontal pixel scale (HPS) = " + nist_txt_field

            'Reads Type-15 record Vertical pixel scale (VPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "VPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "VPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Vertical pixel scale (VPS) = " + nist_txt_field

            'Reads Type-15 record Compression algorithm (CGA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "CGA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "CGA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Compression algorithm (CGA) = " + nist_txt_field

            'Reads Type-15 record Bits per pixel (BPX)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "BPX") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "BPX") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Bits per pixel (BPX) = " + nist_txt_field

            'Reads Type-15 record Palmprint position (PLP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "PLP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "PLP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Palmprint position (PLP) = " + nist_txt_field

            'Reads Type-15 record Scanned horizontal pixel scale (SHPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "SHPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "SHPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Scanned horizontal pixel scale (SHPS) = " + nist_txt_field

            'Reads Type-15 record Scanned vertical pixel scale (SVPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "SVPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "SVPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Scanned vertical pixel scale (SVPS) = " + nist_txt_field

            'Reads Type-15 record Comment (COM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "COM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "COM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Comment (COM) = " + nist_txt_field

            'Reads Type-15 record Palmprint quality metric (PQM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "PQM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "PQM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Palmprint quality metric (PQM) = " + nist_txt_field

            'Reads Type-15 record Device monitoring mode (DMM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(15, idc, -1, "DMM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(15, idc, -1, "DMM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-15 (" + FORMAT$(idc) + ") record Device monitoring mode (DMM) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(15, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Variable-resolution palmprint image was extracted from Type-15 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF



            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(16) TO type_16_number_of_records
            output_message = "Type-16 number of records = " + STR$(type_16_number_of_records)

            MSGBOX output_message


            ' Reads NIST file and shows fingerprint images on the screen.
            FOR i = 1 TO type_16_number_of_records

            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(16, i) TO idc

            'Reads Type-16 record Logical record length (LEN)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "LEN") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "LEN") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = "Type-16 (" + FORMAT$(idc) + ") record Logical record length (LEN) = " + nist_txt_field

            'Reads Type-16 record Image designation character (IDC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "IDC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "IDC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Image designation character (IDC) = " + nist_txt_field


            'Reads Type-16 record User-Defined Image (UDI)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "UDI") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "UDI") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record User-Defined Image (UDI) = " + nist_txt_field

            'Reads Type-16 record Source Agency / ORI (SRC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "SRC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "SRC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Source Agency / ORI (SRC) = " + nist_txt_field

            'Reads Type-16 record User-Defined Testing Date (UTD)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "UTD") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "UTD") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record User-Defined Testing Date (UTD) = " + nist_txt_field

            'Reads Type-16 record Horizontal Line Length (HLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "HLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "HLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Horizontal Line Length (HLL) = " + nist_txt_field

            'Reads Type-16 record Vertical Line Length (VLL)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "VLL") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "VLL") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Vertical Line Length (VLL) = " + nist_txt_field

            'Reads Type-16 record Scale Units (SLC)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "SLC") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "SLC") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Scale Units (SLC) = " + nist_txt_field

            'Reads Type-16 record Horizontal Pixel Scale (HPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "HPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "HPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Horizontal Pixel Scale (HPS) = " + nist_txt_field

            'Reads Type-16 record Vertical Pixel Scale (VPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "VPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "VPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Vertical Pixel Scale (VPS) = " + nist_txt_field

            'Reads Type-16 record Compression Algorithm (CGA)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "CGA") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "CGA") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Compression Algorithm (CGA) = " + nist_txt_field

            'Reads Type-16 record Bits Per Pixel (BPX)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "BPX") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "BPX") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Bits Per Pixel (BPX) = " + nist_txt_field

            'Reads Type-16 record Color Space (CSP)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "CSP") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "CSP") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Color Space (CSP) = " + nist_txt_field

            'Reads Type-16 record Scanned Horizontal Pixel Scale (SHPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "SHPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "SHPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Scanned Horizontal Pixel Scale (SHPS) = " + nist_txt_field

            'Reads Type-16 record Scanned Vertical Pixel Scale (SVPS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "SVPS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "SVPS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Scanned Vertical Pixel Scale (SVPS) = " + nist_txt_field

            'Reads Type-16 record Comment (COM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "COM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "COM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Comment (COM) = " + nist_txt_field

            'Reads Type-16 record User-Defined Testing Image Quality Score (UQS)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "UQS") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "UQS") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record User-Defined Testing Image Quality Score (UQS) = " + nist_txt_field

            'Reads Type-16 record Device Monitoring Mode (DMM)
            CALL DWORD NISTLibrary_Param.DProcs.pReadSizeOfRecordTxtField USING ReadSizeOfRecordTxtField(16, idc, -1, "DMM") TO size_of_byte_array
            ' Returns contents of NIST file data field as text string (char array).
            CALL DWORD NISTLibrary_Param.DProcs.pReadRecordTxtField USING ReadRecordTxtField(16, idc, -1, "DMM") TO lpszBuffer
            nist_txt_field = PEEK$(lpszBuffer, size_of_byte_array)
            output_message = output_message + CHR$(10) + CHR$(13) + "Type-16 (" + FORMAT$(idc) + ") record Device Monitoring Mode (DMM) = " + nist_txt_field


            ' Converts NIST file binary field contents into HBITMAP image.
            ' Returns image in HBITMAP format if successful, returns NULL otherwise.
            CALL DWORD NISTLibrary_Param.DProcs.pCreateHBITMAPfromRecordBinaryField USING CreateHBITMAPfromRecordBinaryField(16, idc) TO hBitmap

             IF hBitmap = 0 THEN
             MSGBOX "Error: unable to convert binary field into HBITMAP"
             EXIT FUNCTION
             END IF

             IF hBitmap THEN
                 hDC = getDC (CBHNDL)
                 IF hDC <> 0 THEN hDCBmp = CreateCompatibleDC( hDC )
                 hBmpOld = SelectObject( hDCBmp, hBitmap )
                 GetObject hBitmap, SIZEOF( pic ), pic
                 InvalidateRect CBHNDL, BYVAL 0, 1
                 output_message = output_message + CHR$(10) + CHR$(13) + "Variable-resolution user-defined testing image was extracted from Type-16 record binary field" + CHR$(10) + CHR$(13) + "of NIST file and converted into HBITMAP for showing on form."
                 MSGBOX output_message
             END IF





            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret






        CONTROL ENABLE CBHNDL, 100&
        CONTROL ENABLE CBHNDL, 101&
        CONTROL ENABLE CBHNDL, 102&
        CONTROL ENABLE CBHNDL, 103&
        CONTROL ENABLE CBHNDL, 104&
        CONTROL ENABLE CBHNDL, 105&
        HourGlass = 0 : MOUSEPTR 1 'Default


'====================================================================================
          CASE 104 'Delete Single Field
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION



        CONTROL DISABLE CBHNDL, 100&
        CONTROL DISABLE CBHNDL, 101&
        CONTROL DISABLE CBHNDL, 102&
        CONTROL DISABLE CBHNDL, 103&
        CONTROL DISABLE CBHNDL, 104&
        CONTROL DISABLE CBHNDL, 105&
        HourGlass = 1 : MOUSEPTR 11 'HourGlass



        'Sets input file name as "sample.nist" which located in "input" subdirectory
        filedirectory = programfilepath + "input\"
        filename = filedirectory + "sample.nist"


        IF NOT Exist(filename) THEN
            MSGBOX "Error: file .\input\sample.nist does not exist."
            RETURN
        END IF


        ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) TO ret before
        ' any further processing of NIST file.
        CALL DWORD NISTLibrary_Param.DProcs.pReadNISTFromFile USING ReadNISTFromFile (filename) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(2) TO type_2_number_of_records

            'Modifies NIST file, Deletes all Type-2 records.
            FOR i = 1 TO type_2_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(2, i) TO idc 'selects the first Type-2 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(2, (type_2_number_of_records - i + 1)) TO idc 'selects the last Type-2 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(2, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(2) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(4) TO type_4_number_of_records

            'Modifies NIST file, Deletes all Type-4 records.
            FOR i = 1 TO type_4_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(4, i) TO idc 'selects the first Type-4 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(4, (type_4_number_of_records - i + 1)) TO idc 'selects the last Type-4 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(4, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(4) TO ret



CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(7) TO type_7_number_of_records

            'Modifies NIST file, Deletes all Type-7 records
            FOR i = 1 TO type_7_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(7, i) TO idc 'selects the first Type-7 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(7, (type_7_number_of_records - i + 1)) TO idc 'selects the last Type-7 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(7, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(7) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(8) TO type_8_number_of_records

            'Modifies NIST file, Deletes all Type-8 records
            FOR i = 1 TO type_8_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(8, i) TO idc 'selects the first Type-8 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(8, (type_8_number_of_records - i + 1)) TO idc 'selects the last Type-8 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(8, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(8) TO ret


CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(9) TO type_9_number_of_records

            'Modifies NIST file, Deletes all Type-9 records
            FOR i = 1 TO type_9_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(9, i) TO idc 'selects the first Type-9 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(9, (type_9_number_of_records - i + 1)) TO idc 'selects the last Type-9 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(9, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(9) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(10) TO type_10_number_of_records

            'Modifies NIST file, Deletes all Type-10 records
            FOR i = 1 TO type_10_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(10, i) TO idc 'selects the first Type-10 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(10, (type_10_number_of_records - i + 1)) TO idc 'selects the last Type-10 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(10, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(10) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(13) TO type_13_number_of_records

            'Modifies NIST file, Deletes all Type-13 records
            FOR i = 1 TO type_13_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(13, i) TO idc 'selects the first Type-13 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(13, (type_13_number_of_records - i + 1)) TO idc 'selects the last Type-13 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(13, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(13) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(14) TO type_14_number_of_records

            'Modifies NIST file, Deletes all Type-14 records
            FOR i = 1 TO type_14_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(14, i) TO idc 'selects the first Type-14 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(14, (type_14_number_of_records - i + 1)) TO idc 'selects the last Type-14 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(14, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(14) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(15) TO type_15_number_of_records

            'Modifies NIST file, Deletes all Type-15 records
            FOR i = 1 TO type_15_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(15, i) TO idc 'selects the first Type-15 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(15, (type_15_number_of_records - i + 1)) TO idc 'selects the last Type-15 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(15, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(15) TO ret




CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret
IF (ret = 1) THEN

            CALL DWORD NISTLibrary_Param.DProcs.pReadNumberOfRecords USING ReadNumberOfRecords(16) TO type_16_number_of_records

            'Modifies NIST file, Deletes all Type-16 records
            FOR i = 1 TO type_16_number_of_records

            'CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(16, i) TO idc 'selects the first Type-16 record
            CALL DWORD NISTLibrary_Param.DProcs.pReadIDCofRecord USING ReadIDCofRecord(16, (type_16_number_of_records - i + 1)) TO idc 'selects the last Type-16 record
            CALL DWORD NISTLibrary_Param.DProcs.pDeleteRecord USING DeleteRecord(16, idc) TO ret

            NEXT i

END IF 'CALL DWORD NISTLibrary_Param.DProcs.pCheckIfRecordTypeExists USING CheckIfRecordTypeExists(16) TO ret








        'Sets output file name as "sample_of_deletion.nist" (in "output" subdirectory) TO ret
        filedirectory = programfilepath + "output\"
        'If output directory does not exist then create output directory
         IF NOT Exist(filedirectory) THEN
         MKDIR (filedirectory)
         END IF

        filename = filedirectory + "sample_of_deletion.nist"


        'Saves NIST into the file "sampleofdeletion.nist" (in "output" subdirectory) TO ret
        CALL DWORD NISTLibrary_Param.DProcs.pWriteNISTToFile USING WriteNISTToFile (filename) TO ret

        MSGBOX "NIST file " + CHR$(34) + ".\input\sample.nist" + CHR$(34) + " was read, modified" + CHR$(10) + CHR$(13) + "and saved as " + CHR$(34) + ".\output\sample_of_deletion.nist" + CHR$(34) + "" + CHR$(10) + CHR$(13) + _
        "Please use " + CHR$(34) + "NIST viewer" + CHR$(34) + " to see changes in" + CHR$(10) + CHR$(13) + "" + CHR$(34) + "sample_of_deletion.nist" + CHR$(34) + " file."



        CONTROL ENABLE CBHNDL, 100&
        CONTROL ENABLE CBHNDL, 101&
        CONTROL ENABLE CBHNDL, 102&
        CONTROL ENABLE CBHNDL, 103&
        CONTROL ENABLE CBHNDL, 104&
        CONTROL ENABLE CBHNDL, 105&
        HourGlass = 0 : MOUSEPTR 1 'Default


'====================================================================================



          CASE 105 'Register
            IF NISTLibrary_LoadLibrary = 0 THEN EXIT FUNCTION
            CALL DWORD NISTLibrary_Param.DProcs.pRegisterNIST
'====================================================================================

        END SELECT




      CASE %WM_DESTROY
         IF  hBitmap < > 0  THEN
            SelectObject hDCBmp, hBmpOld
            DeleteDC hDCBmp
         END IF
         ReleaseDC CBHNDL, hDC

      CASE %WM_SIZING
         InvalidateRect CBHNDL, BYVAL 0, 1

      CASE %WM_PAINT
         hDCPaint = BeginPaint( CBHNDL, ps )
         IF hDCPaint = %NULL THEN EXIT FUNCTION
         IF hBitmap <> 0 THEN

             GetClientRect CBHNDL, tRect

                BitBlt hDCPaint, 0, 0, pic.bmWidth, pic.bmHeight  , hDCBmp, 0, 0, %SRCCOPY

            'The commented code below forces auto-resizing of image
            ' IF pic.bmWidth < tRect.nRight AND pic.bmHeight < tRect.nBottom THEN
            '    BitBlt hDCPaint, 0, 0, pic.bmWidth, pic.bmHeight  , hDCBmp, 0, 0, %SRCCOPY
            ' ELSEIF pic.bmWidth > tRect.nRight AND pic.bmHeight < tRect.nBottom THEN
            '    StretchBlt hDCPaint, 0, 0, tRect.nRight, pic.bmHeight, hDCBmp, 0, 0, pic.bmWidth, pic.bmHeight, %SRCCOPY
            ' ELSEIF pic.bmWidth < tRect.nRight AND pic.bmHeight > tRect.nBottom THEN
            '    StretchBlt hDCPaint, 0, 0, pic.bmWidth, tRect.nBottom, hDCBmp, 0, 0, pic.bmWidth, pic.bmHeight, %SRCCOPY
            ' ELSE 'pic.bmWidth > tRect.nRight AND pic.bmHeight > tRect.nBottom THEN
            '    StretchBlt hDCPaint, 0, 0, tRect.nRight, tRect.nBottom , hDCBmp, 0, 0, pic.bmWidth, pic.bmHeight, %SRCCOPY
            ' END IF
         END IF
         EndPaint CBHNDL, ps
    END SELECT

END FUNCTION

FUNCTION WINMAIN ( BYVAL hCurInstance  AS LONG, _
                   BYVAL hPrevInstance AS LONG, _
                   BYVAL lpszCmdLine   AS ASCIIZ PTR, _
                   BYVAL nCmdShow      AS LONG ) AS LONG

    DIM hDlg    AS LONG
    DIM Result  AS LONG
    DIM hDC AS LONG
    DIM hfidib AS LONG
    LOCAL Buffer AS STRING
    LOCAL fHandle AS DWORD
    LOCAL sFile AS STRING

    IF NISTLibrary_LoadLibrary = 0 THEN
        MSGBOX "Unable to load NIST Library"
        EXIT FUNCTION
    END IF

    sFile = "" 'Add a full, valid path & filename here if needed.


    OPEN sFile FOR BINARY AS #1
    GET$ #1, LOF( 1), Buffer
    CLOSE #1

    fHandle = STRPTR( Buffer)


    DIALOG NEW 0, "NIST Library Demo",,, 340, 280 _
        ,  %WS_OVERLAPPED _
        OR %WS_SYSMENU _
        OR %WS_MINIMIZEBOX _
        OR %WS_MAXIMIZEBOX _
        OR %WS_THICKFRAME _
        OR %WS_CLIPSIBLINGS _
        OR %WS_CLIPCHILDREN _
        TO hDlg

    IF hDlg = 0 THEN EXIT FUNCTION



    DIALOG SHOW MODAL hDlg CALL DlgProc TO Result


    IF hBitmap THEN DeleteObject hBitmap

    NISTLibrary_FreeLibrary

    FUNCTION = 1

END FUNCTION






'---------------------------------------------------------
'OpenFile and SaveFile Dialog initializations

SUB InitOpenFileDlg(BYVAL hWnd AS LONG)
STATIC strFilter AS STRING
STATIC strIniDir AS STRING



strFilter = "NIST files"+CHR$(0)+"*.nist"+CHR$(0)+"All files"+CHR$(0)+"*.*"+CHR$(0)+CHR$(0)


'strIniDir="C:\Program Files"
ofn.lStructSize=SIZEOF(OPENFILENAME)
ofn.hWndOwner=hWnd
ofn.hInstance=%NULL
ofn.lpstrFilter=STRPTR(strFilter)
ofn.nMaxFile=%MAX_PATH
ofn.nMaxFileTitle=%MAX_PATH+%MAX_EXT
ofn.lpstrInitialDir = STRPTR(strIniDir)
ofn.lpstrDefExt=%NULL
ofn.lpstrFile=VARPTR(szFileName)
ofn.lpstrFileTitle=VARPTR(szTitleName)
END SUB

SUB ShowOpenFileDlg(hWnd AS LONG, BYVAL pstrFileName AS ASCIIZ PTR, BYVAL pstrFileTitle AS ASCIIZ PTR)
ofn.lpstrFile=pstrFileName
ofn.lpstrFileTitle=pstrFileTitle
ofn.Flags=%OFN_HIDEREADONLY OR %OFN_CREATEPROMPT
CALL GetOpenFileName(ofn)
END SUB
