unit Version;

interface
  function VersionString: string;
  function FN: string;
  function _BuildNumber: string;
  function BuildNumber: string;
implementation
  uses
    verinfo, SysUtils, uUtility;
  const
    __FN: string = '';                      { this filename }
    __VS: string = '';
    __BN: string = '';

  function VersionString: string;
  begin
    if __VS='' then __VS := 'Ver: ' + GetVersionInformation( viFileVersion, false );
    result := __VS;
  end;

  function FN: string;
  begin
     if __FN='' then __FN := ExtractFileNameNoExt( ParamStr(0) );
    result := __FN;
  end;

  function _BuildNumber: string;
  var
    i: integer;
  begin
    if __BN='' then
    begin
      __BN := GetVersionInformation( viFileVersion, false );
      repeat
        i := Pos( '.', __BN );
        if i>0 then Delete( __BN, 1, i );
      until i < 1;
    end;
    result := __BN;
  end;

  function BuildNumber: string;
  var
    i: integer;
  begin
    if __BN='' then
    begin
      __BN := GetVersionInformation( viFileVersion, false );
      repeat
        i := Pos( '.', __BN );
        if i>0 then Delete( __BN, 1, i );
      until i < 1;
    end;
    result := 'Build '+__BN;
  end;

end.

