SRL Archive - OSR Help

How to combine this into 1 procedure


rj

2013-06-19 14:30:04

Ok, so I want to combine my Tsender procedures into 1, I know it's possible but I'm not sure how to:

procedure Quit(Sender: TObject);
begin
Pressed := False;
Writeln('Script stopped');
DsgnForm.CLOSE;
end;
procedure Antimsg(Sender: TObject);
begin
case (CheckBoxs[0].Checked) of
True: writeln('ANTI BAN ON');
False: writeln('ANTI BAN OFF');
end;
end;
procedure progressmsg(Sender: TObject);
begin
case (CheckBoxs[1].Checked) of
True: writeln('PAINT ON');
False: writeln('PAINT OFF');
end;
end;
procedure bankmsg(Sender: TObject);
begin
case (CheckBoxs[2].Checked) of
True: writeln('BANK HIGHLIGHTING ON');
False: writeln('BANK HIGHLIGHTING OFF');
end;
end;
procedure modmsg(Sender: TObject);
begin
case (CheckBoxs[2].Checked) of
True: writeln('LOGOUT ON MOD ON');
False: writeln('LOGOUT ON MOD OFF');
end;
end;

That just seems repetitive

Olly

2013-06-19 14:49:17

procedure foo(sender: TObject);
begin
case sender of
checkBoxs[0]:
begin
end;

checkBoxs[1]:
begin
end;
end;
end;

Brandon

2013-06-19 14:52:06

EDIT: Ninja'd


var
frmMain: TForm;
Params: TVariantArray;

procedure OnClick(Sender: TObject);
begin
if (Sender = frmMain) then //Check who the sender is to determine what to do..
writeln('MEh');
end;

procedure InitialiseForm;
begin
frmMain := TForm.Create(nil);
frmMain.OnClick := @OnTick;
frmMain.ShowModal;
end;

begin
ThreadSafeCall('InitialiseForm', Params);

frmMain.Close;
frmMain.Free;
end.

rj

2013-06-19 14:59:56

thanks for the help guys i got it:

Procedure ObjectHit(Sender: TObject);
begin
case sender of
CheckBoxs[0]:
begin
case (CheckBoxs[0].Checked) of
True: writeln('ANTI BAN ON');
False: writeln('ANTI BAN OFF');
end;
end;
CheckBoxs[1]:
begin
case (CheckBoxs[1].Checked) of
True: writeln('PAINT ON');
False: writeln('PAINT OFF');
end;
end;
CheckBoxs[2]:
begin
case (CheckBoxs[2].Checked) of
True: writeln('BANK HIGHLIGHTING ON');
False: writeln('BANK HIGHLIGHTING OFF');
end;
end;
CheckBoxs[3]:
begin
case (CheckBoxs[3].Checked) of
True: writeln('LOGOUT ON MOD ON');
False: writeln('LOGOUT ON MOD OFF');
end;
end;
end;
end;

Not done yet though