You are here: Symbol Reference > RndGenerators Namespace > Classes > TRandomGenerator Class > public > TRandomGenerator.LoadFromFile Method
MtxVec VCL
ContentsIndex
PreviousUpNext
TRandomGenerator.LoadFromFile Method

Loads random generator state from File.

Pascal
procedure LoadFromFile(const FileName: string); virtual;
var rnd: TRandomGenerator; iVec: VectorInt; begin rnd := TRandomGenerator.Create; rnd.StreamIndependence := TRngStreamIndependence.rsiLeapfrog; try iVec.Size(1000); rnd.StreamCount := 2; rnd.Stream[0].RandomUniformbitsI(iVec); rnd.Stream[1].RandomUniformbitsI(iVec); rnd.SaveToFile('D:Test.rnd'); finally rnd.Free; end; rnd := TRandomGenerator.Create; //load stream count, and individual stream state at the time when they were saved rnd.LoadFromFile('D:Test.rnd'); try //continue where we left of:... rnd.Stream[0].RandomUniformbitsI(iVec); rnd.Stream[1].RandomUniformbitsI(iVec); finally rnd.Free; end; end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!