Load

Declaration: TParticles.Load (FName: string; var DataID: string; var SizeX, SizeY: integer; var RefSpectra: string): integer;
The function Load reads particle data which have been stored by the method Save. The parameter FName specifies the filename of the particle data. The variable parameter DataID returns the unique data identifier which has been defined when saving the data. This parameter can be used to ensure that the loaded particle data are compatible to the currently loaded data.

The variable parameters SizeX and SizeY specify the lateral size (in pixel) of the current datacube. Particle data can only be loaded if the size of the current datacube and the particle data match. Thus, you have to pass the lateral sizes (in pixels) of the currently loaded datacube when calling the function. In the case of a mismatch, an error is returned (error code -2) and the two parameters are set to the size of the particle data.

On return the variable parameter RefSpectra will contain the path to the corresponding reference spectra (see Save for details).

The function returns the following error codes:

 0 ... everything is OK, data has been loaded successfully
-1 ... (undefined)
-2 ... the size of stored particle data does not match SizeX/SizeY
-3 ... the file FName does not exist or the file is broken

Hint: In order to access the particles currently loaded in the particle editor you can use the pre-declared global variable PEData.

Example: The following code snippet shows how to correctly call the Load function in order to load a set of particles into the particle editor:
var
  sx, sy   : integer;
  RefSpecs : string;
  DataID   : string;

...
...
sx := MData.SizeX;
sy := MData.SizeY;
errnum := PEData.Load ('particlefile.part', DataID, sx, sy, RefSpecs);
if errnum = 0 then
  begin
    // proceed with loaded particle data
  end;
...
...