UNIT Unit10_leveldb;
INTERFACE
USES
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, StrUtils;

TYPE
  TForm10 = Class(TForm)
    group_progress: TGroupBox;
    progress: TProgressBar;
    lbl_progress: TLabel;
    btn_abortok: TButton;
    lbl_estimation: TLabel;
    PROCEDURE btn_abortokClick(Sender: TObject);
  PRIVATE
    PROCEDURE HandleFile(ext:String; fileid:LongWord; dir_dat2db:Boolean);
    PROCEDURE stop_convert;
  PUBLIC
    PROCEDURE CreateDatabase(source,target:String);
    PROCEDURE CreateLevel(source,target:String);
  END;


VAR
  Form10: TForm10;

IMPLEMENTATION
{$R *.dfm}
USES ABSMain, ABSDecUtil, Unit1_main, Unit2_functions, Unit3_data, Unit6_imgfuncs, Unit9_data_structures, Unit15_Classes;

TYPE
  THandler=PROCEDURE(fileid:LongWord; dir_dat2db:Boolean);
  TConvertHandlers=RECORD
    Ext:String[4];
    needed:Boolean;
    Handler:THandler;
  END;
VAR
  ConvertHandlers:Array OF TConvertHandlers;
  loaded_filename:String;
  converting:Boolean=False;
  abort:Boolean=False;
  DataBase:TABSDatabase;
  Query:TABSQuery;
  MimeCoder: TStringFormat_MIME64;
VAR
  DatHeader:THeader;
  FilesHeader:TFilesMap;
  NamedFilesHeader:TNamedFilesMap;
  ExtensionsHeader:TExtensionsMap;
  Stream_Body,Stream_Names:TMemoryStream;
  Stream_Dat,Stream_Raw,Stream_Sep:TFileStream;

PROCEDURE TForm10.CreateLevel(source,target:String);
  VAR
    files:LongWord;
    
    i,j:LongWord;
    temps,temps2:String;
    data,rawdata:Tdata;
    absolutebegintime,begintime:Double;
    step:Byte;
    rawlist:TRawList;
    extlist:TExtensionsMap;
    fileinfo:TFileInfo;
    datlinks:TDatLinks;
    OniImage:TOniImage;
    levelid:LongWord;
  CONST
    steps:Byte=3;
  PROCEDURE DoStep(stepname:String);
    BEGIN
      Inc(step);
      IF stepname<>'FIN' THEN
        group_progress.Caption:='Creating Dat (Step '+IntToStr(step)+'/'+IntToStr(steps)+': '+stepname+')'
      ELSE
        group_progress.Caption:='Creating Dat (FINISHED)';
    END;
  BEGIN

//
// FILE EXISTS CHECK FÜR DAT/RAW/SEP!!!
//

    IF NOT CreateDataConnection(source,ODB_ADB) THEN BEGIN
      ShowMessage('Could not connect to .oldb-file');
      Exit;
    END;
    levelid:=OniDataConnection.LevelInfo.LevelNumber;
    levelid:=(levelid*2) SHR (3*8) + $01;
    OniImage:=TOniImage.Create;

    absolutebegintime:=Time;

    Form10.Visible:=True;
    Form1.Visible:=False;
    step:=0;
    converting:=True;
    abort:=False;
    btn_abortok.Caption:='&Abort...';
    btn_abortok.Default:=False;
    absolutebegintime:=Time;

    Stream_Body:=TMemoryStream.Create;
    Stream_Names:=TMemoryStream.Create;
    Stream_Dat:=TFileStream.Create(target,fmCreate);
    Stream_Raw:=TFileStream.Create(AnsiReplaceStr(target,'.dat','.raw'),fmCreate);
    IF OniDataConnection.OSisMac THEN
      Stream_Sep:=TFileStream.Create(AnsiReplaceStr(target,'.dat','.sep'),fmCreate);

    DoStep('Creating header');
    progress.Position:=0;
    lbl_progress.Caption:='';
    lbl_estimation.Caption:='Estimated finishing time: unknown';
    Application.ProcessMessages;

    NamedFilesHeader:=TOniDataADB(OniDataConnection).GetNamedFilesMap;
    extlist:=OniDataConnection.GetExtendedExtensionsList;
    FOR i:=0 TO High(DatHeader.Ident) DO
      DatHeader.Ident[i]:=OniDataConnection.LevelInfo.Ident[i];
    DatHeader.Files:=OniDataConnection.GetFilesCount;
    DatHeader.NamedFiles:=Length(NamedFilesHeader);
    DatHeader.Extensions:=Length(extlist);
    DatHeader.DataAddr:=0;
    DatHeader.DataSize:=0;
    DatHeader.NamesAddr:=0;
    DatHeader.NamesSize:=0;
    FOR i:=0 TO High(DatHeader.Ident2) DO
      DatHeader.Ident2[i]:=0;
    SetLength(FilesHeader, DatHeader.Files);
    SetLength(ExtensionsHeader, DatHeader.Extensions);

    DoStep('Writing extensions-header');
    progress.Max:=Length(OniDataConnection.GetExtensionsList);
    Application.ProcessMessages;

    FOR i:=0 TO High(ExtensionsHeader) DO BEGIN
      ExtensionsHeader[i].Ident:=extlist[i].Ident;
      ExtensionsHeader[i].Extension:=extlist[i].Extension;
      SetLength(temps,4);
      FOR j:=0 TO 3 DO
        temps[j+1]:=ExtensionsHeader[i].Extension[3-j];
      ExtensionsHeader[i].ExtCount:=Length(OniDataConnection.GetFilesList(temps,'',False));
      progress.Position:=i+1;
      lbl_progress.Caption:='Extensions done: '+IntToStr(i+1)+'/'+IntToStr(Length(extlist));
      Application.ProcessMessages;
    END;

    DoStep('Storing files-data');
    progress.Position:=0;
    progress.Max:=DatHeader.Files;
    lbl_progress.Caption:='';
    lbl_estimation.Caption:='Estimated finishing time: unknown';
    Application.ProcessMessages;

    begintime:=Time;
    FOR i:=0 TO DatHeader.Files-1 DO BEGIN
      fileinfo:=OniDataConnection.GetFileInfo(i);
      FOR j:=0 TO 3 DO
        FilesHeader[i].Extension[j]:=fileinfo.Extension[4-j];
      IF fileinfo.Size>0 THEN BEGIN
//        DatLinks:=;
        FilesHeader[i].DataAddr:=Stream_Body.Size+8;
        data:=OniDataConnection.LoadDatFile(i);


        IF (Pos(UpperCase(fileinfo.Extension),UpperCase(raws)) MOD 4)=1 THEN BEGIN
          rawlist:=OniDataConnection.GetRawList(i);
          IF Length(rawlist)>0 THEN BEGIN
            FOR j:=0 TO High(rawlist) DO BEGIN
              IF rawlist[j].raw_size>0 THEN BEGIN
                IF (UpperCase(fileinfo.Extension)='TXMP') AND ((data[$88] AND $01)>0) THEN BEGIN
                  OniImage.LoadFromTXMP(i);
                  OniImage.GetMipMappedImage(rawdata);
                  rawlist[j].raw_size:=OniImage.GetImageDataSize(true);
                  data[$90]:=08;
                END ELSE BEGIN
                  SetLength(rawdata,rawlist[j].raw_size);
                  OniDataConnection.LoadRawFile(i,rawlist[j].src_offset,@rawdata[0]);
                END;

                IF rawlist[j].loc_sep THEN BEGIN
                  rawlist[j].raw_addr:=Stream_Sep.Size;
                  Stream_Sep.Write(rawdata[0],Length(rawdata));
                END ELSE BEGIN
                  rawlist[j].raw_addr:=Stream_Raw.Size;
                  Stream_Raw.Write(rawdata[0],Length(rawdata));
                END;
              END ELSE rawlist[j].raw_addr:=0;
              data[rawlist[j].src_offset+0]:=(rawlist[j].raw_addr       ) AND $FF;
              data[rawlist[j].src_offset+1]:=(rawlist[j].raw_addr SHR  8) AND $FF;
              data[rawlist[j].src_offset+2]:=(rawlist[j].raw_addr SHR 16) AND $FF;
              data[rawlist[j].src_offset+3]:=(rawlist[j].raw_addr SHR 24) AND $FF;
            END;
          END;
        END;

        Stream_Body.Write(data[0],Length(data));
//
      END ELSE
        FilesHeader[i].DataAddr:=0;
      IF Length(fileinfo.Name)>0 THEN BEGIN
        FilesHeader[i].NameAddr:=Stream_Names.Size;
        temps:=fileinfo.Extension+fileinfo.Name+Chr(0);
        Stream_Names.Write(temps[1],Length(temps)); 
      END ELSE
        FilesHeader[i].NameAddr:=0;
      FilesHeader[i].FileSize:=fileinfo.Size;
      FilesHeader[i].FileType:=fileinfo.FileType;

      IF ( (i MOD 25)=0 ) AND (i>=100) THEN
        lbl_estimation.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/i*progress.Max+begintime);
      progress.Position:=i+1;
      lbl_progress.Caption:='Files done: '+IntToStr(i+1)+'/'+IntToStr(progress.Max);
      Application.ProcessMessages;
    END;

    Stream_Dat.Write(DatHeader,SizeOf(DatHeader));
    FOR i:=0 TO High(FilesHeader) DO
      Stream_Dat.Write(FilesHeader[i],SizeOf(FilesHeader[i]));
    FOR i:=0 TO High(NamedFilesHeader) DO
      Stream_Dat.Write(NamedFilesHeader[i],SizeOf(NamedFilesHeader[i]));
    FOR i:=0 TO High(ExtensionsHeader) DO
      Stream_Dat.Write(ExtensionsHeader[i],SizeOf(ExtensionsHeader[i]));

    DatHeader.DataSize:=Stream_Body.Size;
    DatHeader.NamesSize:=Stream_Names.Size;
    DatHeader.DataAddr:=Stream_Dat.Size;
    Stream_Body.Seek(0,soFromBeginning);
    Stream_Dat.CopyFrom(Stream_Body,Stream_Body.Size);
    DatHeader.NamesAddr:=Stream_Dat.Size;
    Stream_Names.Seek(0,soFromBeginning);
    Stream_Dat.CopyFrom(Stream_Names,Stream_Names.Size);

    Stream_Dat.Seek(0,soFromBeginning);
    Stream_Dat.Write(DatHeader,SizeOf(DatHeader)); 

    Stream_Dat.Free;
    Stream_Body.Free;
    Stream_Names.Free;
    Stream_Raw.Free;
    IF OniDataConnection.OSisMac THEN
      Stream_Sep.Free;

    progress.Position:=progress.Max;
    lbl_progress.Caption:='Files done: '+IntToStr(progress.Max)+'/'+IntToStr(progress.Max);
    lbl_estimation.Caption:='FINISHED (duration: '+TimeToStr(Time-absolutebegintime)+')';

    DoStep('FIN');
    btn_abortok.Caption:='&OK';
    btn_abortok.Default:=True;

    OniImage.Free;

    converting:=False;

    CloseDataConnection;
  END;

PROCEDURE TForm10.HandleFile;
  VAR
    i:Byte;
  BEGIN
    FOR i:=1 TO Length(ConvertHandlers) DO
      IF UpperCase(ConvertHandlers[i].Ext)=UpperCase(ext) THEN
        IF ConvertHandlers[i].needed THEN BEGIN
          ConvertHandlers[i].Handler(fileid, dir_dat2db);
          Break;
        END ELSE
          Break;
  END;

PROCEDURE TForm10.CreateDatabase(source,target:String);
  VAR
    i,j:LongWord;
    temps,temps2:String;
    data:Tdata;
    absolutebegintime,begintime:Double;
    step:Byte;
    rawlist:TRawList;
    extlist:TExtensionsMap;
    fileinfo:TFileInfo;
  CONST
    steps:Byte=4;
  PROCEDURE DoStep(stepname:String);
    BEGIN
      Inc(step);
      IF stepname<>'FIN' THEN
        group_progress.Caption:='Creating DB (Step '+IntToStr(step)+'/'+IntToStr(steps)+': '+stepname+')'
      ELSE
        group_progress.Caption:='Creating DB (FINISHED)';
    END;
  BEGIN
    IF NOT CreateDataConnection(source,ODB_Dat) THEN BEGIN
      ShowMessage('Could not connect to .dat-file');
      Exit;
    END ELSE BEGIN
      TOniDataDat(OniDataConnection).UnloadWhenUnused:=False;
    END;

    Form10.Visible:=True;
    Form1.Visible:=False;
    step:=0;
    converting:=True;
    abort:=False;
    btn_abortok.Caption:='&Abort...';
    btn_abortok.Default:=False;
    loaded_filename:=target;

    absolutebegintime:=Time;

    DataBase:=TABSDatabase.Create(Self);
    DataBase.DatabaseName:='OLDB';
    DataBase.DatabaseFileName:=target;
    DataBase.CreateDatabase;

    DoStep('Creating tables');
    progress.Position:=0;
    lbl_progress.Caption:='';
    lbl_estimation.Caption:='Estimated finishing time: unknown';
    Application.ProcessMessages;

    Query:=TABSQuery.Create(Self);
    Query.DatabaseName:='OLDB';
    Query.SQL.Text:='CREATE TABLE globals  ( id AUTOINC PRIMARY KEY, name STRING(128), value STRING(128) );';
    Query.ExecSQL;
    Query.SQL.Text:='CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );';
    Query.ExecSQL;
    Query.SQL.Text:='CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, sep BOOLEAN, size INTEGER, data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
//    Query.SQL.Text:='CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
    Query.ExecSQL;
    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
//    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
    Query.ExecSQL;
    Query.SQL.Text:='CREATE TABLE extlist  ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
    Query.ExecSQL;

    Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("dbversion","'+dbversion+'");';
    Query.ExecSQL;
    SetLength(data,Length(OniDataConnection.LevelInfo.Ident));
    FOR i:=0 TO High(OniDataConnection.LevelInfo.Ident) DO data[i]:=OniDataConnection.LevelInfo.Ident[i];
    temps:=CreateHexString(data,True);
    Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("ident","'+temps+'");';
    Query.ExecSQL;
    Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("lvl","'+IntToStr(OniDataConnection.LevelInfo.LevelNumber)+'");';
    Query.ExecSQL;
    IF OniDataConnection.OSisMAC THEN
      Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("os","MAC");'
    ELSE
      Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("os","PC");';
    Query.ExecSQL;

    DoStep('Writing extensionslist');
    progress.Max:=Length(OniDataConnection.GetExtensionsList);
    Application.ProcessMessages;

    extlist:=OniDataConnection.GetExtendedExtensionsList;
    FOR i:=0 TO High(extlist) DO BEGIN
      SetLength(data,Length(extlist[i].Ident));
      FOR j:=0 TO High(extlist[i].Ident) DO data[j]:=extlist[i].Ident[j];
      temps:=CreateHexString(data,True);
      temps2:=extlist[i].Extension[3]+extlist[i].Extension[2]+extlist[i].Extension[1]+extlist[i].Extension[0];
      Query.SQL.Text:='INSERT INTO extlist (ext,ident) VALUES ("'+temps2+'","'+temps+'");';
      Query.ExecSQL;
      progress.Position:=i;
      lbl_progress.Caption:='Extensions done: '+IntToStr(i)+'/'+IntToStr(Length(extlist));
      Application.ProcessMessages;
      IF abort THEN BEGIN
        stop_convert;
        Exit;
      END;
    END;
    lbl_progress.Caption:='';

    progress.Position:=0;
    lbl_progress.Caption:='Files done: '+IntToStr(0)+'/'+IntToStr(OniDataConnection.GetFilesCount);
    lbl_estimation.Caption:='Estimated finishing time: unknown';

    DoStep('Loading .dat into memory');
    Application.ProcessMessages;

    progress.Max:=OniDataConnection.GetFilesCount;
    begintime:=Time;
    DoStep('Writing .dat-fileslist');
    Application.ProcessMessages;

    Database.StartTransaction;
    FOR i:=0 TO OniDataConnection.GetFilesCount-1 DO BEGIN
      fileinfo:=OniDataConnection.GetFileInfo(i);
      IF (fileinfo.FileType AND $02)=0 THEN BEGIN
        mimecoder:=TStringFormat_MIME64.Create;
        data:=OniDataConnection.LoadDatFile(i);
        Query.SQL.Text:='INSERT INTO datfiles (id,extension,name,contenttype,size,data) VALUES ('+IntToStr(i)+',"'+fileinfo.Extension+'","'+fileinfo.Name+'","'+IntToHex(fileinfo.FileType,8)+'",'+IntToStr(fileinfo.Size)+',MimeToBin("'+MimeCoder.StrTo(@data[0], Length(data))+'") );';
        Query.ExecSQL;
        mimecoder.Free;

        rawlist:=OniDataConnection.GetRawList(i);
        IF Length(rawlist)>0 THEN BEGIN
          FOR j:=0 TO High(rawlist) DO BEGIN
            IF rawlist[j].raw_size>0 THEN BEGIN
              SetLength(data, rawlist[j].raw_size);
              OniDataConnection.LoadRawFile(i,rawlist[j].src_offset,data);
              mimecoder:=TStringFormat_MIME64.Create;
              Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,sep,size,data) VALUES ('+IntToStr(i)+','+IntToStr(rawlist[j].src_offset)+','+BoolToStr(rawlist[j].loc_sep)+','+IntToStr(rawlist[j].raw_size)+',MimeToBin("'+MimeCoder.StrTo(@data[0], rawlist[j].raw_size)+'") );';
              Query.ExecSQL;
              mimecoder.Free;
            END ELSE BEGIN
              Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,sep,size) VALUES ('+IntToStr(i)+','+IntToStr(rawlist[j].src_offset)+','+BoolToStr(rawlist[j].loc_sep)+',0);';
              Query.ExecSQL;
            END;
          END;
        END;

        HandleFile(fileinfo.Extension,i,True);
      END ELSE BEGIN
        Query.SQL.Text:='INSERT INTO datfiles (id,extension,name,contenttype,size) VALUES ('+IntToStr(i)+',"'+fileinfo.Extension+'","'+fileinfo.Name+'","'+IntToHex(fileinfo.FileType,8)+'",0);';
        Query.ExecSQL;
      END;
      IF ( (i MOD 100)=0 ) AND (i>0) THEN BEGIN
        Database.Commit(False);
        Database.StartTransaction;
      END;
      IF ( (i MOD 25)=0 ) AND (i>=100) THEN
        lbl_estimation.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/i*progress.Max+begintime);
      progress.Position:=i;
      lbl_progress.Caption:='Files done: '+IntToStr(i)+'/'+IntToStr(progress.Max);
      Application.ProcessMessages;
      IF abort THEN BEGIN
        stop_convert;
        Exit;
      END;
    END;
    Database.Commit(False);
    progress.Position:=progress.Max;
    lbl_progress.Caption:='Files done: '+IntToStr(progress.Max)+'/'+IntToStr(progress.Max);
    lbl_estimation.Caption:='FINISHED (duration: '+TimeToStr(Time-absolutebegintime)+')';

    DoStep('FIN');
    btn_abortok.Caption:='&OK';
    btn_abortok.Default:=True;

    converting:=False;

    database.Close;
    database.Free;

    CloseDataConnection;
  END;

PROCEDURE TForm10.stop_convert;
  BEGIN
    btn_abortok.Caption:='&Close';
    btn_abortok.Default:=True;
    converting:=False;
    lbl_estimation.Caption:='ABORTED';
    group_progress.Caption:='Creating DB (ABORTED)';
    DataBase.Close;
    IF MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'), PChar('Delete file?'), MB_YESNO)=IDYES THEN BEGIN
      DeleteFile(loaded_filename);
    END;
  END;

PROCEDURE TForm10.btn_abortokClick(Sender: TObject);
  BEGIN
    IF converting THEN BEGIN
      IF MessageBox(Self.Handle, PChar('Do you really want to cancel the convert-progress?'), PChar('Warning: Converting'), MB_YESNO)=IDYES THEN
        abort:=True;
    END ELSE BEGIN
      Form10.Visible:=False;
      Form1.Visible:=True;
    END;
  END;

PROCEDURE InsertDatLinkToDB(fileid:LongWord; offset:LongWord);
  VAR
    link:LongWord;
  BEGIN
    OniDataConnection.LoadDatFilePart(fileid,offset,4,@link);
    IF link=0 THEN
      link:=$FFFFFFFF
    ELSE
      link:=link DIV 256;
    Query.SQL.Text:='INSERT INTO linkmap (src_id,src_link_offset,target_id) VALUES ('+IntToStr(fileid)+','+IntToStr(offset)+','+IntToStr(link)+');';
    Query.ExecSQL;
  END;

PROCEDURE AISA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:Word;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN BEGIN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*$160+$28);
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*$160+$150);
      END;
    END ELSE BEGIN
    END;
  END;
PROCEDURE AKEV(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 16 DO InsertDatLinkToDB(fileid,$8+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE AKOT(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$8+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE CBPI(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 56 DO InsertDatLinkToDB(fileid,$8+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE CBPM(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 18 DO InsertDatLinkToDB(fileid,$8+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE CONS(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$24+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE CRSA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$14,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*1100+$A0);
    END ELSE BEGIN
    END;
  END;
PROCEDURE DOOR(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
      InsertDatLinkToDB(fileid,$10);
    END ELSE BEGIN
    END;
  END;
PROCEDURE DPGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$40);
    END ELSE BEGIN
    END;
  END;
PROCEDURE HPGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$0C);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IGHH(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$24);
      InsertDatLinkToDB(fileid,$28);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IGPA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    links:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@links);
      IF links>0 THEN
        FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IGPG(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$1C+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IGSA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    links:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@links);
      IF links>0 THEN
        FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IMPT(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$10);
    END ELSE BEGIN
    END;
  END;
PROCEDURE IPGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$0C);
    END ELSE BEGIN
    END;
  END;
PROCEDURE KEYI(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 9 DO InsertDatLinkToDB(fileid,$08+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE M3GA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    links:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@links);
      IF links>0 THEN
        FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE M3GM(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 6 DO InsertDatLinkToDB(fileid,$0C+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE MTRL(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$10);
    END ELSE BEGIN
    END;
  END;
PROCEDURE OBDC(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:Word;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*$18+$4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE OBOA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:Word;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO BEGIN
          InsertDatLinkToDB(fileid,$20+i*240+$0);
          InsertDatLinkToDB(fileid,$20+i*240+$4);
          InsertDatLinkToDB(fileid,$20+i*240+$8);
        END;
    END ELSE BEGIN
    END;
  END;
PROCEDURE OFGA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+$04);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONCC(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$28);
      InsertDatLinkToDB(fileid,$434);
      InsertDatLinkToDB(fileid,$438);
      InsertDatLinkToDB(fileid,$43C);
      InsertDatLinkToDB(fileid,$C3C);
      InsertDatLinkToDB(fileid,$C40);
      InsertDatLinkToDB(fileid,$C44);
      InsertDatLinkToDB(fileid,$C48);
      InsertDatLinkToDB(fileid,$C88);
      InsertDatLinkToDB(fileid,$C8C);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONCV(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONLV(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$48+i*4);
      FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$64+i*4);
      InsertDatLinkToDB(fileid,$300);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONOA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*8+$04);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONSK(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
      InsertDatLinkToDB(fileid,$0C);
      InsertDatLinkToDB(fileid,$10);
      InsertDatLinkToDB(fileid,$14);
      InsertDatLinkToDB(fileid,$18);
      InsertDatLinkToDB(fileid,$20);
      InsertDatLinkToDB(fileid,$44);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONVL(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE ONWC(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$28);
      InsertDatLinkToDB(fileid,$34);
      InsertDatLinkToDB(fileid,$40);
      InsertDatLinkToDB(fileid,$54);
      InsertDatLinkToDB(fileid,$58);
      InsertDatLinkToDB(fileid,$5C);
      InsertDatLinkToDB(fileid,$60);
      InsertDatLinkToDB(fileid,$6FC);
      InsertDatLinkToDB(fileid,$700);
    END ELSE BEGIN
    END;
  END;
PROCEDURE OPGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$0C);
    END ELSE BEGIN
    END;
  END;
PROCEDURE PSPC(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$50);
    END ELSE BEGIN
    END;
  END;
PROCEDURE PSPL(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:LongWord;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*8+$4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE PSUI(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 43 DO InsertDatLinkToDB(fileid,$08+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE STNA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:Word;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRAC(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    packages:Word;
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$18);
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+8);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRAM(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$40);
      InsertDatLinkToDB(fileid,$44);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRAS(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRBS(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$08+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRCM(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      FOR i:=0 TO 2 DO InsertDatLinkToDB(fileid,$5C+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRGA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:Word;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$20);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRIG(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$18);
      InsertDatLinkToDB(fileid,$24);
      InsertDatLinkToDB(fileid,$28);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRMA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:Word;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TRSC(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:Word;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1E,2,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TSFF(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TSFT(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$1C);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TURR(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$60);
      InsertDatLinkToDB(fileid,$6C);
      InsertDatLinkToDB(fileid,$74);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TXAN(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TXMA(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TXMB(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TXMP(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$94);
      InsertDatLinkToDB(fileid,$98);
    END ELSE BEGIN
    END;
  END;
PROCEDURE TXTC(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
    END ELSE BEGIN
    END;
  END;
PROCEDURE WMCL(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*8+$4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE WMDD(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$11C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$120+i*$124+$114);
    END ELSE BEGIN
    END;
  END;
PROCEDURE WMMB(fileid:LongWord; dir_dat2db:Boolean);
  VAR
    i:LongWord;
    packages:LongWord;
  BEGIN
    IF dir_dat2db THEN BEGIN
      OniDataConnection.LoadDatFilePart(fileid,$1C,4,@packages);
      IF packages>0 THEN
        FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
    END ELSE BEGIN
    END;
  END;
PROCEDURE WPGE(fileid:LongWord; dir_dat2db:Boolean);
  BEGIN
    IF dir_dat2db THEN BEGIN
      InsertDatLinkToDB(fileid,$08);
      InsertDatLinkToDB(fileid,$0C);
    END ELSE BEGIN
    END;
  END;

PROCEDURE InsertHandler(ext:String; needed:Boolean; handler:THandler);
  BEGIN
    SetLength(ConvertHandlers,Length(ConvertHandlers)+1);
    ConvertHandlers[High(ConvertHandlers)].Ext:=ext;
    ConvertHandlers[High(ConvertHandlers)].needed:=needed;
    ConvertHandlers[High(ConvertHandlers)].handler:=handler;
  END;

BEGIN
  InsertHandler('ABNA',False,NIL);
//  InsertHandler('AGDB',True,AGDB);
  InsertHandler('AGDB',False,NIL);
  InsertHandler('AGQC',False,NIL);
  InsertHandler('AGQG',False,NIL);
  InsertHandler('AGQR',False,NIL);
  InsertHandler('AISA',True,AISA);
  InsertHandler('AITR',False,NIL);
  InsertHandler('AKAA',False,NIL);
  InsertHandler('AKBA',False,NIL);
  InsertHandler('AKBP',False,NIL);
  InsertHandler('AKDA',False,NIL);
  InsertHandler('AKEV',True,AKEV);
  InsertHandler('AKOT',True,AKOT);
  InsertHandler('AKVA',False,NIL);
  InsertHandler('BINA',False,NIL);
  InsertHandler('CBPI',True,CBPI);
  InsertHandler('CBPM',True,CBPM);
  InsertHandler('CONS',True,CONS);
  InsertHandler('CRSA',True,CRSA);
  InsertHandler('DOOR',True,DOOR);
  InsertHandler('DPGE',True,DPGE);
  InsertHandler('ENVP',False,NIL);
  InsertHandler('FILM',False,NIL);
  InsertHandler('HPGE',True,HPGE);
  InsertHandler('IDXA',False,NIL);
  InsertHandler('IGHH',True,IGHH);
  InsertHandler('IGPA',True,IGPA);
  InsertHandler('IGPG',True,IGPG);
  InsertHandler('IGSA',True,IGSA);
  InsertHandler('IMPT',True,IMPT);
  InsertHandler('IPGE',True,IPGE);
  InsertHandler('KEYI',True,KEYI);
  InsertHandler('M3GA',True,M3GA);
  InsertHandler('M3GM',True,M3GM);
  InsertHandler('MTRL',True,MTRL);
  InsertHandler('OBAN',False,NIL);
  InsertHandler('OBDC',True,OBDC);
  InsertHandler('OBOA',True,OBOA);
  InsertHandler('OFGA',True,OFGA);
  InsertHandler('ONCC',True,ONCC);
  InsertHandler('ONCP',False,NIL);
  InsertHandler('ONCV',True,ONCV);
  InsertHandler('ONFA',False,NIL);
  InsertHandler('ONGS',False,NIL);
  InsertHandler('ONIA',False,NIL);
  InsertHandler('ONLD',False,NIL);
  InsertHandler('ONLV',True,ONLV);
  InsertHandler('ONMA',False,NIL);
  InsertHandler('ONOA',True,ONOA);
  InsertHandler('ONSA',False,NIL);
  InsertHandler('ONSK',True,ONSK);
  InsertHandler('ONTA',False,NIL);
  InsertHandler('ONVL',True,ONVL);
  InsertHandler('ONWC',True,ONWC);
  InsertHandler('OPGE',True,OPGE);
  InsertHandler('OSBD',False,NIL);
  InsertHandler('OTIT',False,NIL);
  InsertHandler('OTLF',False,NIL);
  InsertHandler('PLEA',False,NIL);
  InsertHandler('PNTA',False,NIL);
  InsertHandler('PSPC',True,PSPC);
  InsertHandler('PSPL',True,PSPL);
  InsertHandler('PSUI',True,PSUI);
  InsertHandler('QTNA',False,NIL);
  InsertHandler('SNDD',False,NIL);
  InsertHandler('STNA',True,STNA);
  InsertHandler('SUBT',False,NIL);
  InsertHandler('TRAC',True,TRAC);
  InsertHandler('TRAM',True,TRAM);
  InsertHandler('TRAS',True,TRAS);
  InsertHandler('TRBS',True,TRBS);
  InsertHandler('TRCM',True,TRCM);
  InsertHandler('TRGA',True,TRGA);
  InsertHandler('TRGE',True,TRGE);
  InsertHandler('TRIA',False,NIL);
  InsertHandler('TRIG',True,TRIG);
  InsertHandler('TRMA',True,TRMA);
  InsertHandler('TRSC',True,TRSC);
  InsertHandler('TRTA',False,NIL);
  InsertHandler('TSFF',True,TSFF);
  InsertHandler('TSFL',False,NIL);
  InsertHandler('TSFT',True,TSFT);
  InsertHandler('TSGA',False,NIL);
  InsertHandler('TSTR',False,NIL);
  InsertHandler('TURR',True,TURR);
  InsertHandler('TXAN',True,TXAN);
  InsertHandler('TXCA',False,NIL);
  InsertHandler('TXMA',True,TXMA);
  InsertHandler('TXMB',True,TXMB);
  InsertHandler('TXMP',True,TXMP);
  InsertHandler('TXTC',True,TXTC);
  InsertHandler('VCRA',False,NIL);
  InsertHandler('WMCL',True,WMCL);
  InsertHandler('WMDD',True,WMDD);
  InsertHandler('WMM_',False,NIL);
  InsertHandler('WMMB',True,WMMB);
  InsertHandler('WPGE',True,WPGE);   
END.
