ImportJCampDXSpec

Declaration: ImportJCampDXSpec (FName: string; var Spectrum: TDoubleArray; var Group: integer): integer;
The function ImportJCampDXSpec reads a single spectrum from a JCAMP/DX file. The parameter FName specifies the full file path of the JCAMP/DX file. The variable parameter Spectrum returns the read spectrum, it is automatically resized to hold the entire spectrum. The variable parameter Group contains the spectral group to which the read spectrum belongs.

The spectral values read from the JCAMP/DX file are rescaled to fit the corresponding group of the data cube. If the JCAMP/DX data does not fully cover the range of the spectral group the uncovered parts are set to zero.

The function returns the following error codes:

 0 ... everything is OK, the JCAMP/DX file has been imported
-1 ... the file does not exist
-2 ... spectral type of JCAMP/DX file does not match any of the available groups

Sample Program: The following sample program shows how to import a single spectrum stored in JCAMP/DX format. If successful the imported spectrum is stored in pixel [1,1] of the current data cube.
program ImportJCampDXSpectrum;

var
  Spec           : TDoubleArray;
  errnum         : integer;
  FName          : string;
  grp            : integer;

begin
FName := SelectFile ('', '*.dx', 'Select a jcamp/dx file');
if FName <> '' then
  errnum := ImportJCampDXSpec (FName, Spec, grp);
if (errnum = 0) and (grp > 0) then
  SetSpectrum (1,1,1,grp,Spec);
end.