// extra functions
var
  startTime: Cardinal;

function Max(a, b : integer): integer;
begin
  if a>b then 
    result:=a
  else
    result:=b;
end;

function Min(a, b : integer): integer;
begin
  if a<b then 
    result:=a
  else
    result:=b;
end;

procedure CreateNXAccessComponents(var aSession: TnxSession; var adb: TnxDatabase; var aQuery: TnxQuery; var aTable: TnxTable);
begin
  aSession:=TnxSession.Create(nil);
  adb:=TnxDatabase.Create(nil);
  aQuery:=TnxQuery.Create(nil);
  aTable:=TnxTable.Create(nil);

  // set the session's server engine to the internal nxserver engine
  aSession.ServerEngine:=ServerEngine;

  // link the other instances
  adb.Session:=aSession;
  aQuery.Database:=adb;
  aTable.Database:=adb;
end;