Code:
unit Kaartje;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Jpeg, ClipBrd, DateUtils, Buttons,StrUtils,
ShellAPI, XPMan, ExtCtrls, Menus;
type
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 }
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;
public
{ Public declarations }
end;
procedure Kaarttel;
procedure Klembord;
procedure Rijentel;
procedure Rijenleeg;
procedure Kolommentel;
procedure Kolommenleeg;
procedure Wissen;
var
MyForm: TMyForm;
myDate: TDateTime;
myJaar, myMaand, myDag : Word;
myUur, myMin, mySec, myMilli : Word;
hokje: array[0..143] of TEdit;
num: array[0..143] of integer; // WAARVOOR ?? Weghalen is ERROR
arHokje: Array[1..144] of integer;
codestr0, codestr1, codestr2, codestr3, tmp: String;
x, MC, MaxW: integer;
KaartCode, DagTijd:string;
R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12:integer; // ivm labels optelling
K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12:integer;
AA,BB,CC,DD,EE,FF,GG,HH,II,JJ,KK,LL:integer;
implementation
uses Data, VistaAltFixUnit;
{$R *.dfm}
Procedure Kaarttel;
var k, y ,z: integer;
blVlag: boolean;
begin
kaartcode:='';
k:=0; MC:=0; z:=0;
// WAARDE Rij/Kolom OPTELLINGEN:
K1:=0;K2:=0;K3:=0;K4:=0;K5:=0;K6:=0;K7:=0;K8:=0;K9:=0;K10:=0;K11:=0;K12:=0;
AA:=0;BB:=0;CC:=0;DD:=0;EE:=0;FF:=0;GG:=0;HH:=0;II:=0;JJ:=0;KK:=0;LL:=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
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 Rijentel;
var x, y: integer;
blVlag: boolean;
Begin
// STARTWAARDE OPTELLINGEN:
R1:=0;R2:=0;R3:=0;R4:=0;R5:=0;R6:=0;R7:=0;R8:=0;R9:=0;R10:=0;R11:=0;R12:=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
R1:=R1+arHokje[x];
if arHokje[x]>0 then blVlag:=true; // Start = al False, maakt niet uit hoe vaak>0!
end;
R1:= R1 mod MaxW ; // Uikomst 0 is kaart MaxW !!
if (R1=0) and (blVlag=false) then R1:=0 else if (R1=0) and (blVlag=true) then R1:=MaxW;
myform.R1.Caption:=inttostr(R1);
blVlag:=false;
for x := 12 to 23 do
begin
R2:=R2+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R2:= R2 mod MaxW ;
if (R2=0) and (blVlag=false) then R2:=0 else if (R2=0) and (blVlag=true) then R2:=MaxW;
myform.R2.Caption:=inttostr(R2);
blVlag:=false;
for x := 24 to 35 do
begin
R3:=R3+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R3:= R3 mod MaxW ;
if (R3=0) and (blVlag=false) then R3:=0 else if (R3=0) and (blVlag=true) then R3:=MaxW;
myform.R3.Caption:=inttostr(R3);
blVlag:=false;
for x := 36 to 47 do
begin
R4:=R4+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R4:= R4 mod MaxW ;
if (R4=0) and (blVlag=false) then R4:=0 else if (R4=0) and (blVlag=true) then R4:=MaxW;
myform.R4.Caption:=inttostr(R4);
blVlag:=false;
for x := 48 to 59 do
begin
R5:=R5+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R5:= R5 mod MaxW ;
if (R5=0) and (blVlag=false) then R5:=0 else if (R5=0) and (blVlag=true) then R5:=MaxW;
myform.R5.Caption:=inttostr(R5);
blVlag:=false;
for x := 60 to 71 do
begin
R6:=R6+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R6:= R6 mod MaxW ;
if (R6=0) and (blVlag=false) then R6:=0 else if (R6=0) and (blVlag=true) then R6:=MaxW;
myform.R6.Caption:=inttostr(R6);
blVlag:=false;
for x := 72 to 83 do
begin
R7:=R7+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R7:= R7 mod MaxW ;
if (R7=0) and (blVlag=false) then R7:=0 else if (R7=0) and (blVlag=true) then R7:=MaxW;
myform.R7.Caption:=inttostr(R7);
blVlag:=false;
for x := 84 to 95 do
begin
R8:=R8+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R8:= R8 mod MaxW ;
if (R8=0) and (blVlag=false) then R8:=0 else if (R8=0) and (blVlag=true) then R8:=MaxW;
myform.R8.Caption:=inttostr(R8);
blVlag:=false;
for x := 96 to 107 do
begin
R9:=R9+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R9:= R9 mod MaxW ;
if (R9=0) and (blVlag=false) then R9:=0 else if (R9=0) and (blVlag=true) then R9:=MaxW;
myform.R9.Caption:=inttostr(R9);
blVlag:=false;
for x := 108 to 119 do
begin
R10:=R10+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R10:= R10 mod MaxW ;
if (R10=0) and (blVlag=false) then R10:=0 else if (R10=0) and (blVlag=true) then R10:=MaxW;
myform.R10.Caption:=inttostr(R10);
blVlag:=false;
for x := 120 to 131 do
begin
R11:=R11+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R11:= R11 mod MaxW ;
if (R11=0) and (blVlag=false) then R11:=0 else if (R11=0) and (blVlag=true) then R11:=MaxW;
myform.R11.Caption:=inttostr(R11);
blVlag:=false;
for x := 132 to 143 do // START = 0 !!
begin
R12:=R12+arHokje[x];
if arHokje[x]>0 then blVlag:=true;
end;
R12:= R12 mod MaxW ;
if (R12=0) and (blVlag=false) then R12:=0 else if (R12=0) and (blVlag=true) then R12:=MaxW;
myform.R12.Caption:=inttostr(R12);
End;
procedure Rijenleeg;
Begin
myform.R1.Caption:='---';myform.R2.Caption:='---';myform.R3.Caption:='---';myform.R4.Caption:='---';
myform.R5.Caption:='---';myform.R6.Caption:='---';myform.R7.Caption:='---';myform.R8.Caption:='---';
myform.R9.Caption:='---';myform.R10.Caption:='---';myform.R11.Caption:='---';myform.R12.Caption:='---';
End;
procedure Kolommentel;
var y: integer;
blVlag: boolean;
Begin
// STARTWAARDE OPTELLINGEN:
K1:=0;K2:=0;K3:=0;K4:=0;K5:=0;K6:=0;K7:=0;K8:=0;K9:=0;K10:=0;K11:=0;K12:=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
K1:=K1+arHokje[y];
if arHokje[y]>0 then blVlag:=true; // 1 keer True is genoeg! Alles false = 0
inc (y,12);
end;
K1:= K1 mod MaxW ; // Uikomst 0 is kaart MaxW !!
if (K1=0) and (blVlag=false) then K1:=0 else if (K1=0) and (blVlag=true) then K1:=MaxW;
myform.K1.Caption:=inttostr(K1);
y:=1;
blVlag:=false;
while (y>=1) And (y<=133) do
begin
K2:=K2+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K2:= K2 mod MaxW ;
if (K2=0) and (blVlag=false) then K2:=0 else if (K2=0) and (blVlag=true) then K2:=MaxW;
myform.K2.Caption:=inttostr(K2);
y:=2;
blVlag:=false;
while (y>=2) And (y<=134) do
begin
K3:=K3+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K3:= K3 mod MaxW ;
if (K3=0) and (blVlag=false) then K3:=0 else if (K3=0) and (blVlag=true) then K3:=MaxW;
myform.K3.Caption:=inttostr(K3);
y:=3;
blVlag:=false;
while (y>=3) And (y<=135) do
begin
K4:=K4+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K4:= K4 mod MaxW ;
if (K4=0) and (blVlag=false) then K4:=0 else if (K4=0) and (blVlag=true) then K4:=MaxW;
myform.K4.Caption:=inttostr(K4);
y:=4;
blVlag:=false;
while (y>=4) And (y<=136) do
begin
K5:=K5+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K5:= K5 mod MaxW ;
if (K5=0) and (blVlag=false) then K5:=0 else if (K5=0) and (blVlag=true) then K5:=MaxW;
myform.K5.Caption:=inttostr(K5);
y:=5;
blVlag:=false;
while (y>=5) And (y<=137) do
begin
K6:=K6+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K6:= K6 mod MaxW ;
if (K6=0) and (blVlag=false) then K6:=0 else if (K6=0) and (blVlag=true) then K6:=MaxW;
myform.K6.Caption:=inttostr(K6);
y:=6;
blVlag:=false;
while (y>=6) And (y<=138) do
begin
K7:=K7+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K7:= K7 mod MaxW ;
if (K7=0) and (blVlag=false) then K7:=0 else if (K7=0) and (blVlag=true) then K7:=MaxW;
myform.K7.Caption:=inttostr(K7);
y:=7;
blVlag:=false;
while (y>=7) And (y<=139) do
begin
K8:=K8+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K8:= K8 mod MaxW ;
if (K8=0) and (blVlag=false) then K8:=0 else if (K8=0) and (blVlag=true) then K8:=MaxW;
myform.K8.Caption:=inttostr(K8);
y:=8;
blVlag:=false;
while (y>=8) And (y<=140) do
begin
K9:=K9+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K9:= K9 mod MaxW ;
if (K9=0) and (blVlag=false) then K9:=0 else if (K9=0) and (blVlag=true) then K9:=MaxW;
myform.K9.Caption:=inttostr(K9);
y:=9;
blVlag:=false;
while (y>=9) And (y<=141) do
begin
K10:=K10+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K10:= K10 mod MaxW ;
if (K10=0) and (blVlag=false) then K10:=0 else if (K10=0) and (blVlag=true) then K10:=MaxW;
myform.K10.Caption:=inttostr(K10);
y:=10;
blVlag:=false;
while (y>=10) And (y<=142) do
begin
K11:=K11+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K11:= K11 mod MaxW ;
if (K11=0) and (blVlag=false) then K11:=0 else if (K11=0) and (blVlag=true) then K11:=MaxW;
myform.K11.Caption:=inttostr(K11);
y:=11;
blVlag:=false;
while (y>=11) And (y<=143) do // STAKT = 0 !!
begin
K12:=K12+arHokje[y];
if arHokje[y]>0 then blVlag:=true;
inc (y,12);
end;
K12:= K12 mod MaxW ;
if (K12=0) and (blVlag=false) then K12:=0 else if (K12=0) and (blVlag=true) then K12:=MaxW;
myform.K12.Caption:=inttostr(K12);
end;
procedure 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 Wissen;
var
i, k : 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;
myform.CheckBox1.Checked:= false;
myform.CheckBox2.Checked:= false;
myform.CheckBox3.Checked:= false;
Rijenleeg;
Kolommenleeg;
MyForm.lbMagCard.Caption:='??';
MyForm.meKlembord.Clear;
End;
procedure Klembord;
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];
myform.meKlembord.Clear;
myform.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)=6 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)=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);
// 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
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;
MyForm.lbMagCard.Caption:='??';
If myform.CheckBox3.Checked = True then
begin
Rijentel;
Kolommentel;
end
else if myform.CheckBox1.Checked = True then Rijentel
else if myform.CheckBox2.Checked = True then Kolommentel;
end;
// ------ 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 x:=i;
end;
end;
// ------ Onthoud in welk hokje een pijltoets wordt gebruikt
procedure TMyForm.OnEditBoxesKeyDown(Sender: TObject; var Key: Word; shift: TShiftState);
begin
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}
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;
x:=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
TVistaAltFix.Create(Self);
CreateEditBoxes;
MaxW:=36;
end;
// Einde sourcecode
End.
Bookmarks