Knowing which Rave version an NDR File was made with

Category

Rave - General

Question

How do I know which Rave version an NDR File was made with?

Solution

Whilst the NDR file doesn't contain info about which RAVE version produced it, it does contain a version number. The following overloaded (one for Handle, one for filename) functions get the NDR Version.

interface

{ Assume an Nevrona NDR File is passed, this returns the NDR Version number of
	the file. A result of 0 means no version number found.
}
function NDRVersion (const Handle: Integer): LongInt; overload
function NDRVersion (const FileName: string): LongInt; overload;

implementation

uses
	SysUtils;

function NDRVersion (const Handle: Integer): LongInt;
var
	JobHeader: Byte;
	Version: LongInt;
begin
	Result := 0;
	if Handle < 0 then
		Exit;

	Version := 0;

	FileSeek (Handle, 0, 0);
	if FileRead (Handle, JobHeader, 1) = 1 then
	begin
		if FileRead (Handle, Version, 2) <> 2 then
			Version := 0;
	end;

	Result := Version;
end;

function NDRVersion (const FileName: string): LongInt;
var
	Handle: Integer;
begin
	Handle := FileOpen (FileName, fmOpenRead);
	if Handle > 0 then
	begin
		Result := NDRVersion (Handle);
		FileClose (Handle);
	end
	else
		Result := 0;
end;