unit Kaartje;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
{$IFnDEF FPC}
Jpeg, XPMan,
{$ELSE}
{$ENDIF}
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ClipBrd, DateUtils, Buttons,StrUtils,
ShellAPI, ExtCtrls, Menus, LCLProc;
const
NrEdits = 144;
type
THokjes = array[0..NrEdits-1] of TEdit;
THokjesValues = array[0..NrEdits-1] of Integer;
TMyForm = class(TForm)
CopyCode: TButton;
Shape1: TShape;
btWissen: TButton;
//XPManifest1: TXPManifest;
MAXDeck: TEdit;
K1: TLabel;
K2: TLabel;
K3: TLabel;
K4: TLabel;
K5: TLabel;
K6: TLabel;
K7: TLabel;
K8: TLabel;
K9: TLabel;
K10: TLabel;
K11: TLabel;
K12: TLabel;
R1: TLabel;
R2: TLabel;
R3: TLabel;
R4: TLabel;
R5: TLabel;
R6: TLabel;
R7: TLabel;
R8: TLabel;
R9: TLabel;
R10: TLabel;
R11: TLabel;
R12: TLabel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Uittellen: TButton;
PopupMenu1: TPopupMenu;
N29kaarten1: TMenuItem;
N310kaarten1: TMenuItem;
N3201: TMenuItem;
btHelp: TButton;
lbMagCard: TLabel;
N515kaarten1: TMenuItem;
Label1: TLabel;
lbHorizon: TLabel;
lbVertial: TLabel;
URLlabel: TLabel;
Label2: TLabel;
meKlembord: TMemo;
procedure CopyCodeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure btWissenClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure UittellenClick(Sender: TObject);
procedure N29kaarten1Click(Sender: TObject);
procedure N310kaarten1Click(Sender: TObject);
procedure N3201Click(Sender: TObject);
procedure btHelpClick(Sender: TObject);
procedure MAXDeckChange(Sender: TObject);
procedure N515kaarten1Click(Sender: TObject);
procedure URLlabelClick(Sender: TObject);
private
{ Private declarations }
hokje: THokjes;
arHokje: THokjesValues;
MC, MaxW: Integer;
KaartCode:string;
//FFocusedEditIndex: Integer;
procedure OnEditBoxesKeyPress(Sender: TObject; var Key: Char);
procedure OnEditBoxesChange(Sender: TObject);
procedure OnEditBoxesKeydown (Sender: TObject; var Key: Word; Shift: TShiftState);
procedure CreateEditBoxes; // Free bij FormDestroy
//procedure OnEditBoxesClick(Sender: TObject);
//Deze is noodzakelijk als je de tabtoets wilt gebruiken!
procedure CMDialogKey( Var msg: TCMDialogKey );
message CM_DIALOGKEY;
procedure Kaarttel;
procedure Klembord;
procedure Rijentel;
procedure Rijenleeg;
procedure Kolommentel;
procedure Kolommenleeg;
procedure Wissen;
public
{ Public declarations }
end;
var
MyForm: TMyForm;
//num: array[0..143] of integer; // WAARVOOR ?? Weghalen is ERROR
//codestr0, codestr1, codestr2, codestr3, tmp: String;
//x : integer;
implementation
uses
{$IFnDEF FPC}
VistaAltFixUnit,
{$ELSE}
{$ENDIF}
Data;
{$IFnDEF FPC}
{$R *.dfm}
{$ELSE}
{$R *.lfm}
{$ENDIF}
Procedure TMyForm.Kaarttel;
var k, y: integer;
blVlag: boolean;
begin
kaartcode:='';
k:=0; MC:=0;
blVlag:=false;
for y := 0 to High(hokje) do // is van hokje 1 t/m 144
begin
inc(k,1); // Rijtjes van 12 maken
//-----
if hokje[y].Text <> '' then // Edithokje is standaard tekst
begin
blVlag:=true;
if StrToInt(hokje[y].text) > 0 then // Alle hokjes voor verschillende forums
begin
Inc(MC,strtoint(hokje[y].Text));
if MaxW <= 36 then
kaartcode:=kaartcode+' - '+kaartxt[strtoint(hokje[y].Text)]
else
kaartcode:=kaartcode+' - '+(hokje[y].Text);
end;
end;
//-----
if k=12 then
begin
if blVlag=true then // Knip de verschillende Tekststrings in stukjes van 12
begin
kaartcode:=kaartcode+Chr(13)+Chr(10);
kaartcode:=stringreplace(kaartcode,chr(13)+chr(10)+' -',chr(13)+chr(10),[]);
end;
k:=0;
blVlag:=false;
end;
//-----
end;
Delete(kaartcode,1,2); // De 1e 2 karakters uit de Tekststring strippen.
//--------------------
if MC>MaxW then MC:=MC mod MaxW;
if (MC>0) and (MC<MaxW) then MC:=MC; // RESTWaarde kan natuurlijk 0 zijn!
if (MaxW=36)and (MC>0) and (MC<37) then MyForm.lbMagCard.Caption:=kaartxt[MC]
else MyForm.lbMagCard.Caption:='Nr. '+inttostr(MC);
end;
procedure TMyForm.Rijentel;
var x, y: integer;
blVlag: boolean;
RR1,RR2,RR3,RR4,RR5,RR6,RR7,RR8,RR9,RR10,RR11,RR12:integer; // ivm labels optelling
Begin
// STARTWAARDE OPTELLINGEN:
RR1:=0;RR2:=0;RR3:=0;RR4:=0;RR5:=0;RR6:=0;RR7:=0;RR8:=0;RR9:=0;RR10:=0;RR11:=0;RR12:=0;
//------------------------------
for y := 0 to High(hokje) do // is van hokje 0 t/m 143
begin
//-----
if hokje[y].Text <>'' then // Edithokje is standaard tekst
begin
arHokje[y]:=StrToInt(hokje[y].text); // Vul array met integerwaarde
end else
arHokje[y]:=0;
end;
//----- Nu gaan we optellen... Horizontaal
blVlag:=false; // bij waarde in rijtje vlag = true
for x := 0 to 11 do
begin
RR1:=RR1+arHokje[x];
if arHokje[x]>0 then blVlag:=true; // Start = al False, maakt niet uit hoe vaak>0!
end;
RR1:= RR1 mod MaxW ; // Uikomst 0 is kaart MaxW !!
if (RR1=0) and (blVlag=false) then RR1:=0 else if (RR1=0) and (blVlag=true) then RR1:=MaxW;
R1.Caption:=inttostr(RR1);
blVlag:=false;
for x := 12 to 23 do
begin
RR2:=RR2+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR2:= RR2 mod MaxW ;
if (RR2=0) and (blVlag=false) then RR2:=0 else if (RR2=0) and (blVlag=true) then RR2:=MaxW;
R2.Caption:=inttostr(RR2);
blVlag:=false;
for x := 24 to 35 do
begin
RR3:=RR3+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR3:= RR3 mod MaxW ;
if (RR3=0) and (blVlag=false) then RR3:=0 else
if (RR3=0) and (blVlag=true) then RR3:=MaxW;
R3.Caption:=inttostr(RR3);
blVlag:=false;
for x := 36 to 47 do
begin
RR4:=RR4+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR4:= RR4 mod MaxW ;
if (RR4=0) and (blVlag=false) then RR4:=0 else if (RR4=0) and (blVlag=true) then RR4:=MaxW;
R4.Caption:=inttostr(RR4);
blVlag:=false;
for x := 48 to 59 do
begin
RR5:=RR5+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR5:= RR5 mod MaxW ;
if (RR5=0) and (blVlag=false) then RR5:=0 else if (RR5=0) and (blVlag=true) then RR5:=MaxW;
R5.Caption:=inttostr(RR5);
blVlag:=false;
for x := 60 to 71 do
begin
RR6:=RR6+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR6:= RR6 mod MaxW ;
if (RR6=0) and (blVlag=false) then RR6:=0 else if (RR6=0) and (blVlag=true) then RR6:=MaxW;
R6.Caption:=inttostr(RR6);
blVlag:=false;
for x := 72 to 83 do
begin
RR7:=RR7+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR7:= RR7 mod MaxW ;
if (RR7=0) and (blVlag=false) then RR7:=0 else if (RR7=0) and (blVlag=true) then RR7:=MaxW;
R7.Caption:=inttostr(RR7);
blVlag:=false;
for x := 84 to 95 do
begin
RR8:=RR8+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR8:= RR8 mod MaxW ;
if (RR8=0) and (blVlag=false) then RR8:=0 else if (RR8=0) and (blVlag=true) then RR8:=MaxW;
R8.Caption:=inttostr(RR8);
blVlag:=false;
for x := 96 to 107 do
begin
RR9:=RR9+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR9:= RR9 mod MaxW ;
if (RR9=0) and (blVlag=false) then RR9:=0 else if (RR9=0) and (blVlag=true) then RR9:=MaxW;
R9.Caption:=inttostr(RR9);
blVlag:=false;
for x := 108 to 119 do
begin
RR10:=RR10+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR10:= RR10 mod MaxW ;
if (RR10=0) and (blVlag=false) then RR10:=0 else if (RR10=0) and (blVlag=true) then RR10:=MaxW;
R10.Caption:=inttostr(RR10);
blVlag:=false;
for x := 120 to 131 do
begin
RR11:=RR11+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR11:= RR11 mod MaxW ;
if (RR11=0) and (blVlag=false) then RR11:=0 else if (RR11=0) and (blVlag=true) then RR11:=MaxW;
R11.Caption:=inttostr(RR11);
blVlag:=false;
for x := 132 to 143 do // START = 0 !!
begin
RR12:=RR12+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
RR12:= RR12 mod MaxW ;
if (RR12=0) and (blVlag=false) then RR12:=0 else if (RR12=0) and (blVlag=true) then RR12:=MaxW;
R12.Caption:=inttostr(RR12);
End;
procedure TMyForm.Rijenleeg;
Begin
R1.Caption:='---';R2.Caption:='---';R3.Caption:='---';R4.Caption:='---';
R5.Caption:='---';R6.Caption:='---';R7.Caption:='---';R8.Caption:='---';
R9.Caption:='---';R10.Caption:='---';R11.Caption:='---';R12.Caption:='---';
End;
procedure TMyForm.Kolommentel;
var y: integer;
blVlag: boolean;
KK1,KK2,KK3,KK4,KK5,KK6,KK7,KK8,KK9,KK10,KK11,KK12:integer;
Begin
// STARTWAARDE OPTELLINGEN:
KK1:=0;KK2:=0;KK3:=0;KK4:=0;KK5:=0;KK6:=0;KK7:=0;KK8:=0;KK9:=0;KK10:=0;KK11:=0;KK12:=0;
//------------------------------
for y := 0 to High(hokje) do // is van hokje 0 t/m 143
begin
//-----
if hokje[y].Text <>'' then // Edithokje is standaard tekst
begin
arHokje[y]:=StrToInt(hokje[y].text); // Vul array met integerwaarde
end else
arHokje[y]:=0;
end;
//----- Nu gaan we optellen... Vertikaal
y:=0;
blVlag:=false;
while (y>=0) And (y<=132) do
begin
KK1:=KK1+arHokje[y];
if arHokje[y]>0 then blVlag:=true; // 1 keer True is genoeg! Alles false = 0
inc (y,12);
end;
KK1:= KK1 mod MaxW ; // Uikomst 0 is kaart MaxW !!
if (KK1=0) and (blVlag=false) then KK1:=0 else if (KK1=0) and (blVlag=true) then KK1:=MaxW;
K1.Caption:=inttostr(KK1);
y:=1;
blVlag:=false;
while (y>=1) And (y<=133) do
begin
KK2:=KK2+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK2:= KK2 mod MaxW ;
if (KK2=0) and (blVlag=false) then KK2:=0 else if (KK2=0) and (blVlag=true) then KK2:=MaxW;
K2.Caption:=inttostr(KK2);
y:=2;
blVlag:=false;
while (y>=2) And (y<=134) do
begin
KK3:=KK3+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK3:= KK3 mod MaxW ;
if (KK3=0) and (blVlag=false) then KK3:=0 else if (KK3=0) and (blVlag=true) then KK3:=MaxW;
K3.Caption:=inttostr(KK3);
y:=3;
blVlag:=false;
while (y>=3) And (y<=135) do
begin
KK4:=KK4+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK4:= KK4 mod MaxW ;
if (KK4=0) and (blVlag=false) then KK4:=0 else if (KK4=0) and (blVlag=true) then KK4:=MaxW;
K4.Caption:=inttostr(KK4);
y:=4;
blVlag:=false;
while (y>=4) And (y<=136) do
begin
KK5:=KK5+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK5:= KK5 mod MaxW ;
if (KK5=0) and (blVlag=false) then KK5:=0 else if (KK5=0) and (blVlag=true) then KK5:=MaxW;
K5.Caption:=inttostr(KK5);
y:=5;
blVlag:=false;
while (y>=5) And (y<=137) do
begin
KK6:=KK6+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK6:= KK6 mod MaxW ;
if (KK6=0) and (blVlag=false) then KK6:=0 else if (KK6=0) and (blVlag=true) then KK6:=MaxW;
K6.Caption:=inttostr(KK6);
y:=6;
blVlag:=false;
while (y>=6) And (y<=138) do
begin
KK7:=KK7+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK7:= KK7 mod MaxW ;
if (KK7=0) and (blVlag=false) then KK7:=0 else if (KK7=0) and (blVlag=true) then KK7:=MaxW;
K7.Caption:=inttostr(KK7);
y:=7;
blVlag:=false;
while (y>=7) And (y<=139) do
begin
KK8:=KK8+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK8:= KK8 mod MaxW ;
if (KK8=0) and (blVlag=false) then KK8:=0 else if (KK8=0) and (blVlag=true) then KK8:=MaxW;
K8.Caption:=inttostr(KK8);
y:=8;
blVlag:=false;
while (y>=8) And (y<=140) do
begin
KK9:=KK9+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK9:= KK9 mod MaxW ;
if (KK9=0) and (blVlag=false) then KK9:=0 else if (KK9=0) and (blVlag=true) then KK9:=MaxW;
K9.Caption:=inttostr(KK9);
y:=9;
blVlag:=false;
while (y>=9) And (y<=141) do
begin
KK10:=KK10+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK10:= KK10 mod MaxW ;
if (KK10=0) and (blVlag=false) then KK10:=0 else if (KK10=0) and (blVlag=true) then KK10:=MaxW;
K10.Caption:=inttostr(KK10);
y:=10;
blVlag:=false;
while (y>=10) And (y<=142) do
begin
KK11:=KK11+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK11:= KK11 mod MaxW ;
if (KK11=0) and (blVlag=false) then KK11:=0 else if (KK11=0) and (blVlag=true) then KK11:=MaxW;
K11.Caption:=inttostr(KK11);
y:=11;
blVlag:=false;
while (y>=11) And (y<=143) do // STAKT = 0 !!
begin
KK12:=KK12+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
KK12:= KK12 mod MaxW ;
if (KK12=0) and (blVlag=false) then KK12:=0 else if (KK12=0) and (blVlag=true) then KK12:=MaxW;
K12.Caption:=inttostr(KK12);
end;
procedure TMyForm.Kolommenleeg;
Begin
myform.K1.Caption:='---';myform.K2.Caption:='---';myform.K3.Caption:='---';myform.K4.Caption:='---';
myform.K5.Caption:='---';myform.K6.Caption:='---';myform.K7.Caption:='---';myform.K8.Caption:='---';
myform.K9.Caption:='---';myform.K10.Caption:='---';myform.K11.Caption:='---';myform.K12.Caption:='---';
End;
procedure TMyForm.Wissen;
var
i : integer;
begin
//for k := 0 to 143 do num[k] := 0; // ?? Waarom / arry op 0 zetten moet ook bij start!
for i := 0 to High(hokje) do
begin
hokje[i].Clear;
hokje[i].Color:=clWindow;
end;
CheckBox1.Checked:= false;
CheckBox2.Checked:= false;
CheckBox3.Checked:= false;
Rijenleeg;
Kolommenleeg;
lbMagCard.Caption:='??';
meKlembord.Clear;
End;
procedure TMyForm.Klembord;
var
myDate: TDateTime;
myJaar, myMaand, myDag : Word;
myUur, myMin, mySec, myMilli : Word;
DagTijd: String;
begin
myDate:=Now;
DecodeDateTime(myDate, myJaar, myMaand, myDag,
myUur, myMin, mySec, myMilli);
DagTijd:='Mijn Legging van '+IntToStr(myDag)+ '-' + IntToStr(myMaand)+ '-' +IntToStr(myJaar)+ ' / '
+IntToStr(myUur)+ ':' + IntToStr(myMin)+ ':' + IntToStr(mySec)+chr(10);
Clipboard.AsText:= DagTijd+chr(13)+chr(10)
+kaartcode+chr(13)+chr(10)
+' MagicCard= '+kaartxt[MC];
meKlembord.Clear;
meKlembord.Lines.Add(Clipboard.AsText);
end;
procedure TMyForm.UittellenClick(Sender: TObject);
var
p : TPoint ; // Popup op de juiste plek laten verschijnen -- eig. menu.OwnerDrawn = True !!
begin
P := Uittellen.ClientToScreen(Point(0, Uittellen.Height)); // Point 0 is x,y van Knop
Popupmenu1.Popup(P.X, P.Y);
end;
// ------ Uittellen 2 > 9 krt
procedure TMyForm.N29kaarten1Click(Sender: TObject);
var inkrt1, inkrt2, inx: integer;
begin
if MessageBox(0,'Hokje 1 + 2 wordt uitgeteld tot 3x3=9 kaarten.'+#13+#13
+'k1 + k2 = kaart 3'+#13
+'k4=k3 -- k5=k2+k3 -- k6=k3+k4'+#13
+'k7=k6 -- k8=k5+k6 -- k9=k7+k8'+#13+#13
+'Alle andere hokjes worden GEWIST!'+#13
,'Uittellen?', MB_YesNo)=mrYes then
begin
inkrt1:=0; inkrt2:=0;
if hokje[0].Text<>'' then inkrt1:=strtoint(hokje[0].text); // eerste 2 kaarten bewaar in geheugen
if hokje[1].Text<>'' then inkrt2:=strtoint(hokje[1].text);
Wissen; // alle hokjes wissen
hokje[0].Text:=inttostr(inkrt1); // eerste 2 kaarten weer terugplaatsen
hokje[1].Text:=inttostr(inkrt2);
// Rij 1
inx:=(inkrt1+inkrt2) mod MaxW; if inx=0 then hokje[2].Text:=inttostr(MaxW)
else hokje[2].Text:=inttostr(inx);
// Rij 2
hokje[12].Text:=hokje[2].Text;
inx:=(strtoint(hokje[1].Text)+strtoint(hokje[2].Text)) mod MaxW; if inx=0 then hokje[13].Text:=inttostr(MaxW)
else hokje[13].Text:=inttostr(inx);
inx:=(strtoint(hokje[12].Text)+strtoint(hokje[13].Text)) mod MaxW; if inx=0 then hokje[14].Text:=inttostr(MaxW)
else hokje[14].Text:=inttostr(inx);
// Rij 3
hokje[24].Text:=hokje[14].Text;
inx:=(strtoint(hokje[13].Text)+strtoint(hokje[14].Text)) mod MaxW; if inx=0 then hokje[25].Text:=inttostr(MaxW)
else hokje[25].Text:=inttostr(inx);
inx:=(strtoint(hokje[24].Text)+strtoint(hokje[25].Text)) mod MaxW; if inx=0 then hokje[26].Text:=inttostr(MaxW)
else hokje[26].Text:=inttostr(inx);
end;
Kaarttel; // Voor MagicCard�
end;
// ------ Uittellen 3 > 10 krt
procedure TMyForm.N310kaarten1Click(Sender: TObject);
var
inkrt1, inkrt2, inkrt3, inx: integer;
begin
if MessageBox(0,'Hokjes 1 + 2 + 3 worden uitgeteld tot 10 kaarten.'+#13+#13
+'k1 + k2 + k3 = kaart 4'+#13
+'k5=k1+k2 -- k6=k2+k3 -- k7=k3+k4'+#13
+'k8=k5+k6 -- k9=k7+k8'+#13
+'k10=k8+k9'+#13+#13
+'Alle andere hokjes worden GEWIST!'+#13
,'Uittellen?', MB_YesNo)=mrYes then
begin
inkrt1:=0; inkrt2:=0; inkrt3:=0;
if hokje[0].Text<>'' then inkrt1:=strtoint(hokje[0].text);
if hokje[1].Text<>'' then inkrt2:=strtoint(hokje[1].text);
if hokje[2].Text<>'' then inkrt3:=strtoint(hokje[2].text);
Wissen;
hokje[0].Text:=inttostr(inkrt1);
hokje[1].Text:=inttostr(inkrt2);
hokje[2].Text:=inttostr(inkrt3);
// Rij 1
inx:=(inkrt1+inkrt2+inkrt3) mod MaxW;
if inx=0 then hokje[3].Text:=inttostr(MaxW) else hokje[3].Text:=inttostr(inx);
// Rij 2
inx:=(strtoint(hokje[0].Text)+strtoint(hokje[1].Text)) mod MaxW;
if inx=0 then hokje[12].Text:=inttostr(MaxW) else hokje[12].Text:=inttostr(inx);
inx:=(strtoint(hokje[1].Text)+strtoint(hokje[2].Text)) mod MaxW;
if inx=0 then hokje[13].Text:=inttostr(MaxW) else hokje[13].Text:=inttostr(inx);
inx:=(strtoint(hokje[2].Text)+strtoint(hokje[3].Text)) mod MaxW;
if inx=0 then hokje[14].Text:=inttostr(MaxW) else hokje[14].Text:=inttostr(inx);
// Rij 3
inx:=(strtoint(hokje[12].Text)+strtoint(hokje[13].Text)) mod MaxW;
if inx=0 then hokje[24].Text:=inttostr(MaxW) else hokje[24].Text:=inttostr(inx);
inx:=(strtoint(hokje[13].Text)+strtoint(hokje[14].Text)) mod MaxW;
if inx=0 then hokje[25].Text:=inttostr(MaxW) else hokje[25].Text:=inttostr(inx);
// Rij 4
inx:=(strtoint(hokje[24].Text)+strtoint(hokje[25].Text)) mod MaxW;
if inx=0 then hokje[36].Text:=inttostr(MaxW) else hokje[36].Text:=inttostr(inx);
end;
Kaarttel; // Voor MagicCard�
end;
// ------ Uittellen 3 > 16 krt
procedure TMyForm.N3201Click(Sender: TObject);
var inkrt1, inkrt2, inkrt3, inx: integer;
begin
if MessageBox(0,'Hokjes 1 + 2 + 3 worden uitgeteld tot 16 kaarten.'+#13+#13
+'k1 + k2 + k3 = kaart 4'+#13
+'k5=k1+k2 -- k6=k2+k3 -- k7=k3+k4 -- k8=k5+k6+k7'+#13
+'k9=k5+k6 -- k10=k7+k8 -- k11=k7+k8 -- k12=k9+10+11'+#13
+'k13=k9+k10 -- k14=10+11 -- 15=11+12 -- 16=13+14+15'+#13+#13
+'Alle andere hokjes worden GEWIST!'+#13
,'Uittellen?', MB_YesNo)=6 then
begin
inkrt1:=0; inkrt2:=0; inkrt3:=0;
if hokje[0].Text<>'' then inkrt1:=strtoint(hokje[0].text);
if hokje[1].Text<>'' then inkrt2:=strtoint(hokje[1].text);
if hokje[2].Text<>'' then inkrt3:=strtoint(hokje[2].text);
Wissen;
hokje[0].Text:=inttostr(inkrt1);
hokje[1].Text:=inttostr(inkrt2);
hokje[2].Text:=inttostr(inkrt3);
// Rij 1
inx:=(inkrt1+inkrt2+inkrt3) mod MaxW;
if inx=0 then hokje[3].Text:=inttostr(MaxW) else hokje[3].Text:=inttostr(inx);
// Rij 2
inx:=(strtoint(hokje[0].Text)+strtoint(hokje[1].Text)) mod MaxW;
if inx=0 then hokje[12].Text:=inttostr(MaxW) else hokje[12].Text:=inttostr(inx);
inx:=(strtoint(hokje[1].Text)+strtoint(hokje[2].Text)) mod MaxW;
if inx=0 then hokje[13].Text:=inttostr(MaxW) else hokje[13].Text:=inttostr(inx);
inx:=(strtoint(hokje[2].Text)+strtoint(hokje[3].Text)) mod MaxW;
if inx=0 then hokje[14].Text:=inttostr(MaxW) else hokje[14].Text:=inttostr(inx);
inx:=(strtoint(hokje[12].Text)+strtoint(hokje[13].Text)+strtoint(hokje[14].Text)) mod MaxW;
if inx=0 then hokje[15].Text:=inttostr(MaxW) else hokje[15].Text:=inttostr(inx);
// Rij 3
inx:=(strtoint(hokje[12].Text)+strtoint(hokje[13].Text)) mod MaxW;
if inx=0 then hokje[24].Text:=inttostr(MaxW) else hokje[24].Text:=inttostr(inx);
inx:=(strtoint(hokje[13].Text)+strtoint(hokje[14].Text)) mod MaxW;
if inx=0 then hokje[25].Text:=inttostr(MaxW) else hokje[25].Text:=inttostr(inx);
inx:=(strtoint(hokje[14].Text)+strtoint(hokje[15].Text)) mod MaxW;
if inx=0 then hokje[26].Text:=inttostr(MaxW) else hokje[26].Text:=inttostr(inx);
inx:=(strtoint(hokje[24].Text)+strtoint(hokje[25].Text)+strtoint(hokje[26].Text)) mod MaxW;
if inx=0 then hokje[27].Text:=inttostr(MaxW) else hokje[27].Text:=inttostr(inx);
// Rij 4
inx:=(strtoint(hokje[24].Text)+strtoint(hokje[25].Text)) mod MaxW;
if inx=0 then hokje[36].Text:=inttostr(MaxW) else hokje[36].Text:=inttostr(inx);
inx:=(strtoint(hokje[25].Text)+strtoint(hokje[26].Text)) mod MaxW;
if inx=0 then hokje[37].Text:=inttostr(MaxW) else hokje[37].Text:=inttostr(inx);
inx:=(strtoint(hokje[26].Text)+strtoint(hokje[27].Text)) mod MaxW;
if inx=0 then hokje[38].Text:=inttostr(MaxW) else hokje[38].Text:=inttostr(inx);
inx:=(strtoint(hokje[36].Text)+strtoint(hokje[37].Text)+strtoint(hokje[38].Text)) mod MaxW;
if inx=0 then hokje[39].Text:=inttostr(MaxW) else hokje[39].Text:=inttostr(inx);
end;
Kaarttel; // Voor MagicCard�
end;
// ------ Uittellen 5 > 15 krt
procedure TMyForm.N515kaarten1Click(Sender: TObject);
var inkrt1, inkrt2, inkrt3, inkrt4, inkrt5, inx: integer;
begin
if MessageBox(0,'Hokjes 1 + 2 + 3 + 4 + 5 worden uitgeteld tot 15 kaarten.'+#13+#13
+'k06=k1+k2 -- k07=k2+k3 -- k08=k3+k4 -- k09=k4+k5'+#13
+'k10=k6+k7 -- k11=k7+k8 -- k12=k8+k9'+#13
+'k13=k10+k11 -- k14=k11+k12'+#13
+'k15=k13+k14'+#13+#13
+'Alle andere hokjes worden GEWIST!'+#13
,'Uittellen?', MB_YesNo)=6 then
begin
inkrt1:=0; inkrt2:=0; inkrt3:=0; inkrt4:=0; inkrt5:=0;
if hokje[0].Text<>'' then inkrt1:=strtoint(hokje[0].text);
if hokje[1].Text<>'' then inkrt2:=strtoint(hokje[1].text);
if hokje[2].Text<>'' then inkrt3:=strtoint(hokje[2].text);
if hokje[3].Text<>'' then inkrt4:=strtoint(hokje[3].text);
if hokje[4].Text<>'' then inkrt5:=strtoint(hokje[4].text);
Wissen;
hokje[0].Text:=inttostr(inkrt1);
hokje[1].Text:=inttostr(inkrt2);
hokje[2].Text:=inttostr(inkrt3);
hokje[3].Text:=inttostr(inkrt4);
hokje[4].Text:=inttostr(inkrt5);
//// Rij 1 // Valt weg?
// inx:=(inkrt1+inkrt2+inkrt3+inkrt4+inkrt5) mod MaxW;
// if inx=0 then hokje[3].Text:=inttostr(MaxW) else hokje[3].Text:=inttostr(inx);
// Rij 2
inx:=(strtoint(hokje[0].Text)+strtoint(hokje[1].Text)) mod MaxW;
if inx=0 then hokje[12].Text:=inttostr(MaxW) else hokje[12].Text:=inttostr(inx);
inx:=(strtoint(hokje[1].Text)+strtoint(hokje[2].Text)) mod MaxW;
if inx=0 then hokje[13].Text:=inttostr(MaxW) else hokje[13].Text:=inttostr(inx);
inx:=(strtoint(hokje[2].Text)+strtoint(hokje[3].Text)) mod MaxW;
if inx=0 then hokje[14].Text:=inttostr(MaxW) else hokje[14].Text:=inttostr(inx);
inx:=(strtoint(hokje[3].Text)+strtoint(hokje[4].Text)) mod MaxW;
if inx=0 then hokje[15].Text:=inttostr(MaxW) else hokje[15].Text:=inttostr(inx);
// Rij 3
inx:=(strtoint(hokje[12].Text)+strtoint(hokje[13].Text)) mod MaxW;
if inx=0 then hokje[24].Text:=inttostr(MaxW) else hokje[24].Text:=inttostr(inx);
inx:=(strtoint(hokje[13].Text)+strtoint(hokje[14].Text)) mod MaxW;
if inx=0 then hokje[25].Text:=inttostr(MaxW) else hokje[25].Text:=inttostr(inx);
inx:=(strtoint(hokje[14].Text)+strtoint(hokje[15].Text)) mod MaxW;
if inx=0 then hokje[26].Text:=inttostr(MaxW) else hokje[26].Text:=inttostr(inx);
// Rij 4
inx:=(strtoint(hokje[24].Text)+strtoint(hokje[25].Text)) mod MaxW;
if inx=0 then hokje[36].Text:=inttostr(MaxW) else hokje[36].Text:=inttostr(inx);
inx:=(strtoint(hokje[25].Text)+strtoint(hokje[26].Text)) mod MaxW;
if inx=0 then hokje[37].Text:=inttostr(MaxW) else hokje[37].Text:=inttostr(inx);
// Rij 5
inx:=(strtoint(hokje[36].Text)+strtoint(hokje[37].Text)) mod MaxW;
if inx=0 then hokje[48].Text:=inttostr(MaxW) else hokje[48].Text:=inttostr(inx);
end;
Kaarttel; // Voor MagicCard
end;
// ------ Vertikaal / Horizontaal - 3x Optellingen kiezen
procedure TMyForm.CheckBox1Click(Sender: TObject);
begin
If myform.CheckBox1.Checked = True then
begin
myform.CheckBox2.Checked:= False;
myform.CheckBox3.Checked:= False;
Kolommenleeg;
Rijentel;
end else Rijenleeg;
end;
procedure TMyForm.CheckBox2Click(Sender: TObject);
begin
If myform.CheckBox2.Checked = True then
begin
myform.CheckBox1.Checked:= False;
myform.CheckBox3.Checked:= False;
Rijenleeg;
Kolommentel;
end
else Kolommenleeg;
end;
procedure TMyForm.CheckBox3Click(Sender: TObject);
begin
If myform.CheckBox3.Checked = True then
begin
myform.CheckBox1.Checked:= False;
myform.CheckBox2.Checked:= False;
Rijentel;
Kolommentel;
end else
begin
Rijenleeg;
Kolommenleeg;
end;
end;
procedure TMyForm.CreateEditBoxes;
var i:integer;
begin
for i := 0 to 143 do
begin
hokje[i] := TEdit.Create(nil);
with hokje[i] do
begin
parent:=MyForm;
top:= 40 + trunc(i/12)*22; // is ? rijen van 12 kaarten >
left:=40 + i mod 12*22; // bij for 0-35 do
height:=21;
width:=21;
MaxLength:=2;
tag := i; // ter identificatie mogen ook de zelfde nummers hebben
OnKeyPress := OnEditBoxesKeyPress;
OnChange := OnEditBoxesChange;
OnKeydown:= OnEditBoxesKeydown;
//OnClick:= OnEditBoxesClick;
end;
end;
end;
// ------ MAXIMUM Kaarten
procedure TMyForm.MAXDeckChange(Sender: TObject);
begin
MaxW:=StrToInt(MaxDeck.Text);
MyForm.lbMagCard.Caption:='??';
Wissen;
end;
// Uitgetelde waarde zelf in raster voegen om te gebruiken.
procedure TMyForm.CopyCodeClick(Sender: TObject);
begin
Kaarttel;
Klembord;
end;
procedure TMyForm.btWissenClick(Sender: TObject);
begin
Wissen;
// Wat ook kan:
// for i := 0 to (ComponentCount -1) do begin
// if (Component[i] is TEdit) then
// (Component[i] as TEdit).Clear; // of TEdit(Components[i]).Clear;
// If (Components[I] Is TLabel) And (TLabel(Components[I]).Tag = 1) Then
// TLabel(Components[I]).Caption := ''; // voor alleen sommige labels met tag = 1
//// Controls en ControlCount gebruiken voor andere objecten als het niet lukt
// end;
end;
procedure TMyForm.URLlabelClick(Sender: TObject);
begin
{Vergeet niet bij uses: ShellApi toe te voegen}
ShellExecute(Application.Handle,'open','http://www.marieke-esoterie.nl','',nil,SW_NORMAL);
end;
// ------ Help
procedure TMyForm.btHelpClick(Sender: TObject);
begin
Showmessage('Standaard Kaartnummers zijn 1-36. Lege vakjes worden genegeerd.'+#13+
'Rijen / Kolommen kunnen apart of tegelijk worden uitgeteld.'+#13+
'Op dit moment zijn er alleen titels voor de Lenormand kaarten'+#13+
'Getallen hoger dan 36 kunnen wel worden gebruikt.' +#13+
'Uittellen: geeft verschillende keuzes voor een speciale legging.'+#13+
'Met de Entertoets wordt opnieuw de MagicCard berekend.'+#13+#13+
'Kopieer met de Kopieerknop de uitkomst naar het pc-geheugen en'+#13+
'plak de code vervolgens in de doellocatie met de toetsen Ctrl+V.'+#13+
'Toets Esc = Sluiten.'+#13+
'(vs 1.0 26.09.2021)');
end;
// ------ Zet Kleur in hokje en Voer telling uit
procedure TMyForm.OnEditBoxesChange(Sender: TObject);
var i: integer;
begin
//writeln('OnEditBoxesChange');
for i := 0 to High(hokje) do
begin
if hokje[i].text <> '' then
if StrToInt(hokje[i].text) > MaxW then
begin
hokje[i].text := '';
hokje[i].Color:=clWindow;
end else
if StrToInt(hokje[i].text) > 0 then
hokje[i].Color:=clYellow else hokje[i].color:=clMoneyGreen
else hokje[i].Color:=clWindow;
end;
lbMagCard.Caption:='??';
If CheckBox3.Checked = True then
begin
Rijentel;
Kolommentel;
end
else if CheckBox1.Checked = True then Rijentel
else if CheckBox2.Checked = True then Kolommentel;
end;
//OPM BB: Niet meer nodig
// ------ Onthoud in welk hokje een muisklik is
//procedure TMyform.OnEditBoxesClick(Sender: TObject);
//var i:integer;
//begin
// for i := 0 to High(hokje) do
// begin
// if hokje[i].Focused = true then
// begin
// FFocusedEditIndex:=i;
// Exit;
// end;
// end;
//end;
// ------ Onthoud in welk hokje een pijltoets wordt gebruikt
procedure TMyForm.OnEditBoxesKeyDown(Sender: TObject; var Key: Word; shift: TShiftState);
var
x: Integer;
begin
x := (Sender as TEdit).Tag;
Case Key of
VK_Left :
begin
if x >= 1 then
begin
dec(x,1);
hokje[x].SetFocus;
end;
end;
VK_Right:
begin
if x <= 142 then
begin
inc(x,1);
hokje[x].SetFocus;
end;
end;
VK_UP :
begin
if x >= 12 then
begin
dec(x,12);
hokje[x].SetFocus;
end;
end;
VK_DOWN :
begin
if x < 132 then
begin
inc(x,12);
hokje[x].SetFocus;
end;
end;
VK_TAB : // was niet zo simpel! Zie procedure dialogkey
begin
if x <= 142 then
begin
inc(x,1);
hokje[x].SetFocus;
end;
end;
end;
//====
end;
// ------ Controleer op geldige input
procedure TMyForm.OnEditBoxesKeyPress(Sender: TObject; var Key: Char);
begin
{ Deze proecedure wordt uitgevoerd als een van je 144 editboxes een keypress signaleerd }
//Self.Caption := Key; // ? is dit nodig - zonder gaat ook.
if not (Key in ['1'..'9', #10, #8]) then Key := #0;
// #0 = geen toets. //#37, #38, #39, #40 = pijlen
{combineer:['a'..'z','A'..'Z'], #48=0 of andere ascii waarde - zie nummerceck.txt
// #3, #8, #13,#22, #24, #9, #10 = Ctrl C, Backspace, EnterRet, Ctrl V, Ctrl X, TAB, Enter.
// if Key in [#13] then form1.Convert1Click(nil)end; // Handig bij 1 knop = Enteren}
//OPM BB: is het getal "10" verboden om in te typen?
end;
// ------ Om VK_TAB toets te kunnen gebruiken op form niveau
procedure TMyForm.CMDialogKey(var msg: TCMDialogKey);
begin
if msg.Charcode <> VK_TAB then // lees onderaan hoe het precies zit
inherited; // wordt benut in de OnEditBoxesKeyDown procedure
end;
procedure TMyForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
If Key = VK_ESCAPE then Close; // is event plus prop keypreview moet aan!
If Key = VK_RETURN then CopyCodeClick(Self); // is event plus prop keypreview moet aan!
end;
procedure TMyForm.FormShow(Sender: TObject);
begin
hokje[0].setfocus;
//self.FFocusedEditIndex := 0;
end;
procedure TMyForm.FormDestroy(Sender: TObject);
var
i: integer;
begin
for i := 0 to 143 do
hokje[i].Free;
end;
procedure TMyForm.FormCreate(Sender: TObject);
begin
CreateEditBoxes;
MaxW:=36;
end;
End.
Bookmarks