I'm hoping that someone can see my problem, it's baffling me (but I am a newbie to this so apologies).
My code falls over right at the end:
library TomGenuineWithForm;
{$mode objfpc}{$H+}
uses
SysUtils,
windows,
forms,
math,
diceDlg in 'diceDlg.pas' {PickDiceDlg};
{$R *.res}
var
RandomizeAlreadyCalled: Boolean = False;
//make sure the call is stdcall;
function Dice: Integer; {$ifdef windows}stdcall{$else}cdecl{$endif};
//function Dice: Integer; stdcall;
var
D1, D2: Integer;
T : Dword;
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;
//If form do not exists create it
if PickDiceDlg=nil then
application.CreateForm(TPickDiceDlg,PickDiceDlg);
With PickDiceDlg do
Begin
//Show the form
if not Visible then
Show;
//If delay
if cbWait.checked then
Begin
//Display the next dice to come
lNextdice.caption := Inttostr(MaxIntValue([D1,D2]))+ Inttostr(MinIntValue([D1,D2]));
lNextdice2.visible := true;
lNextdice.visible := true;
//Because there is no mesage loop, force the refresh of the form
Repaint;
T := GetTickcount;
//Make a loop that create the delay
//DO NOT use a application.processMessages or equivalent or it will not work
while GetTickcount-T<dword(spDelay.value*1000) do
Begin
end;
//Hide the next dice upon release
lNextdice2.visible := false;
lNextdice.visible := false;
end;
// Add the dice to the top of the list
lbDiceList.items.insert( 0, Inttostr(D1)+Inttostr(D2) );
end;
end;
//Export the dice function by name
exports Dice;
procedure LibraryProc(Reason: Integer);
Begin
//upon exit destroy the form
Case reason of
DLL_PROCESS_DETACH:
if PickDiceDlg<>nil then
PickDiceDlg.free;
end;
end;
begin
//Reinit the Random Number generator
//randomize;
//set the DLl procedure to handle the DLL_PROCESS_DETACH.
dllProc := @LibraryProc;
end.
First error message is "TomGenuineWithForm.pas(83,1) Error: Identifier not found "dllProc""
If I comment out the dllProc := @LibraryProc; line the error message is "TomGenuineWithForm.pas(84,1) Error: Can't open resource file "E:\Office\Lazarus\lcl\TomGenuineWithForm.res".
So frustrating because I've successfully worked my way through dozens of error messages (usually couldn't find file, my bad with path settings) but this one has me stumped......is there supposed to be a TomGenuineWithForm.res file somewhere? I've searched my entire pc in case it had been dropped somewhere obscure but no joy.
I'm so close to getting this over the line, much appreciated if anyone could help.