Recent

Author Topic: This code worked in an old version of Lazarus but not now :-(  (Read 792 times)

chuckles1066

  • New Member
  • *
  • Posts: 20
This code worked in an old version of Lazarus but not now :-(
« on: December 26, 2023, 12:14:22 pm »
Hello,

Thanks to the wonderful people here I was able to create a Windows dice roll dll based on this code

Code: Pascal  [Select][+][-]
  1. library ChucklesGenuine;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. var
  6.   RandomizeAlreadyCalled: Boolean = False;
  7.  
  8. function Dice: Integer; {$ifdef windows}stdcall{$else}cdecl{$endif};
  9. var
  10.   D1, D2: Integer;
  11. begin
  12.   // call randomize once and never again.
  13.   if not RandomizeAlreadyCalled then begin
  14.     Randomize;
  15.     RandomizeAlreadyCalled := True;
  16.   end;
  17.  
  18.   D1 := Random(6) + 1;
  19.   D2 := Random(6) + 1;
  20.  
  21.   Result := D1 * 8 + D2;
  22. end;
  23.  
  24. exports
  25.   Dice;
  26.  
  27. begin
  28. end.
  29.  

I'm now using a new version of Lazarus; I opened the *.lpr file for the above code and simply renamed it and changed the Random(6) lines to Random(4) - I don't want to see 5 or 6 in the dice rolls generated.

It compiled fine but the program (ExtremeGammon) that calls the dll says it's in the wrong format.  The dll filesize is 210kb versus 72kb for the original on which its based so has anyone any thoughts on what's happening?  Has something changed between versions of Lazarus?

Thank you for reading and compliments of the season :-)

tetrastes

  • Hero Member
  • *****
  • Posts: 755
Re: This code worked in an old version of Lazarus but not now :-(
« Reply #1 on: December 26, 2023, 01:02:45 pm »
The original dll is 32 bit and the new is 64 bit?

chuckles1066

  • New Member
  • *
  • Posts: 20
Re: This code worked in an old version of Lazarus but not now :-(
« Reply #2 on: December 26, 2023, 01:37:35 pm »
The original dll is 32 bit and the new is 64 bit?

Great answer, many thanks!

 

TinyPortal © 2005-2018