Find out which seed randomize has used? lazarus / 61-Beginners ---------------------------------------------------------------------- chuckles1066 · 2020-07-04 14:41 Hello, I have the following bit of code which I am compiling into a dll. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Dice: Integer; {$ifdef windows}stdcall{$else}cdecl{$endif};var  D1, D2: Integer;begin  // call randomize once and never again.  if not RandomizeAlreadyCalled then begin    Randomize;    RandomizeAlreadyCalled := True;  end;   D1 := Random(6) + 1;  D2 := Random(6) + 1;   Result := D1 * 8 + D2;//Export the dice function by nameexports Dice;  Is there a way I can get a message box or a form to pop up telling me what seed (randseed?) value has been used when I've called randomize? Many thanks. ---------------------------------------------------------------------- Blaazen · 2020-07-04 16:05 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // call randomize once and never again.  if not RandomizeAlreadyCalled then begin    Randomize;    ShowMessage(inttostr(RandSeed));     RandomizeAlreadyCalled := True;  end; ---------------------------------------------------------------------- winni · 2020-07-04 16:54 Hi! You can set your RandomSeed by code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Randseed := 19610412; // First man in space: Juri Gagarin Randseed is a DWord. Winni ---------------------------------------------------------------------- wp · 2020-07-04 16:57 Not your question, but I think it is important to know that by setting RandSeed to a given number instead of calling Randomize you can get random numbers which are reproducible from run to run. This is extremely important when you have to debug an error which is related to some specific numbers. Of course this trick should be used only during debugging. [EDIT] Winni was faster... ---------------------------------------------------------------------- chuckles1066 · 2020-07-05 07:53 Thanks  to all, much appreciated....very useful to know that you can "hard code" the seed and be able to reproduce the exact sequence time and time again.....definitely good for debugging. ---------------------------------------------------------------------- jamie · 2020-07-05 12:17 Quote from: winni on July 04, 2020, 06:54:59 pmHi! You can set your RandomSeed by code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Randseed := 19610412; // First man in space: Juri Gagarin Randseed is a DWord. Winni Well, according to our present history that is ---------------------------------------------------------------------- Warfley · 2020-07-05 19:10 Quote from: wp on July 04, 2020, 06:57:48 pmOf course this trick should be used only during debugging.Or when you are doing some sort of (scientific) experiment where you publish the results and your result should be exactly reproducable (like a simulation or so, where you want the same events to occur but handle them differently to be comparable) ---------------------------------------------------------------------- Thaddy · 2020-07-05 19:43 Indeed reproducability on a given dataset is really important for statistics in general.. Nothing to do with debugging. ---------------------------------------------------------------------- chuckles1066 · 2020-07-06 09:01 Which has given me an idea......is it possible to inject a number into my dll (first post)? So, have a pop up (or, preferably a form)  that says "what seed do you want?" and the user either writes in a random value like 12345678 or if he leaves it blank the program chooses one? ---------------------------------------------------------------------- balazsszekely · 2020-07-06 11:06 @chuckles1066 See attached projects: 1. Compile dicelibrary.lpi first 2. Copy the dll/so inside the test folder 3. Run the test project ---------------------------------------------------------------------- chuckles1066 · 2020-07-08 07:56 Apologies for the delay in responding, thank you sooooo much for your effort and help, it is truly appreciated. Some of you guys have so much knowledge, I can only aspire to one day be able to give something back to the forum.