SCAR Code:
program New;
var
SantyForm : TForm;
TitleLabel : TLabel;
BirthdayLabel : TLabel;
HoorayLabelOne : TLabel;
HoorayLabelTwo : TLabel;
BirthdayEdit : TEdit;
SingButton : TButton;
CancelButton : TButton;
Background : TImage;
Sing : Boolean;
BirthdayName : string;
procedure ContinueScript;
begin
if (BirthdayEdit.Text = ' Birthday Person''s Name') then
begin
ShowMessage('Fill In Birthday Person''s Name!');
Exit;
end;
BirthdayName := BirthdayEdit.Text;
SantyForm.ModalResult := mrOk;
Sing := True;
end;
procedure GenerateOnClicks(Senders : TObject);
begin
case Senders of
SingButton : ContinueScript;
CancelButton : SantyForm.ModalResult := mrCancel;
end;
end;
procedure BirthdayFormShow;
var
WhiteBitmap, BlackBitmap : Integer;
begin
SantyForm := CreateForm;
with SantyForm do
begin
Position := poScreenCenter;
BorderStyle := bsNone;
ClientWidth := 421;
ClientHeight := 275;
Font.Name := 'MS Sans Serif';
end;
Background := TImage.Create(SantyForm);
with Background do
begin
Parent := SantyForm;
SetBounds(0, 0, 421, 275);
end;
TitleLabel := TLabel.Create(SantyForm);
with TitleLabel do
begin
Parent := SantyForm;
SetBounds(24, 24, 361, 33);
Caption := 'Santy'#39's HBS - Happy Birthday Singer';
Font.Color := clYellow;
Font.Height := -27;
Font.Name := 'Monotype Corsiva';
end;
BirthdayLabel := TLabel.Create(SantyForm);
with BirthdayLabel do
begin
Parent := SantyForm;
SetBounds(156, 232, 116, 20);
Caption := 'Happy Birthday!!';
Font.Color := clYellow;
Font.Height := -16;
Font.Name := 'MS Sans Serif';
end;
HoorayLabelOne := TLabel.Create(SantyForm);
with HoorayLabelOne do
begin
Parent := SantyForm;
SetBounds(16, 136, 59, 20);
Caption := 'Hooray!!';
Font.Color := clYellow;
Font.Height := -16;
Font.Name := 'MS Sans Serif';
end;
HoorayLabelTwo := TLabel.Create(SantyForm);
with HoorayLabelTwo do
begin
Parent := SantyForm;
SetBounds(344, 136, 59, 20);
Caption := 'Hooray!!';
Font.Color := clYellow;
Font.Height := -16;
Font.Name := 'MS Sans Serif';
end;
BirthdayEdit := TEdit.Create(SantyForm);
with BirthdayEdit do
begin
Parent := SantyForm;
SetBounds(137, 120, 145, 21);
Hint := 'Santy Loves TSN!';
Font.Color := clRed;
Font.Name := 'MS Sans Serif';
ShowHint := True;
Text := ' Birthday Person'#39's Name';
end;
SingButton := TButton.Create(SantyForm);
with SingButton do
begin
Parent := SantyForm;
SetBounds(128, 176, 75, 25);
Caption := 'Sing!';
OnClick := @GenerateOnClicks;
end;
CancelButton := TButton.Create(SantyForm);
with CancelButton do
begin
Parent := SantyForm;
SetBounds(216, 176, 75, 25);
Caption := 'Cancel';
TabOrder := 10;
OnClick := @GenerateOnClicks;
end;
WhiteBitmap := BitmapFromString(1, 1, 'FFFFFF');
BlackBitmap := BitmapFromString(421, 275, '000000');
SafeCopyCanvas(GetBitmapCanvas(BlackBitmap), Background.Canvas, 0, 0, 421, 275, 2, 2, 421, 275);
SafeCopyCanvas(GetBitmapCanvas(WhiteBitmap), Background.Canvas, 0, 0, 1, 1, 0, 0, 2, 421);
SafeCopyCanvas(GetBitmapCanvas(WhiteBitmap), Background.Canvas, 0, 0, 1, 1, 419, 0, 421, 275);
SafeCopyCanvas(GetBitmapCanvas(WhiteBitmap), Background.Canvas, 0, 0, 1, 1, 0, 0, 421, 2);
SafeCopyCanvas(GetBitmapCanvas(WhiteBitmap), Background.Canvas, 0, 0, 1, 1, 0, 273, 421, 275);
end;
procedure SafeBirthdayFormShow;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('BirthdayFormShow', V);
end;
procedure ShowBirthdayFormShowModal;
begin
SantyForm.ShowModal;
end;
procedure SafeShowBirthdayFormShowModal;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowBirthdayFormShowModal', V);
end;
procedure MainBirthdayFormShow;
begin
try
SafeBirthdayFormShow;
SafeShowBirthdayFormShowModal;
finally
FreeForm(SantyForm);
except
WriteLn('An error seems to have occurred in: BirthdayFormShow');
end;
end;
procedure SingHappyBirthday(BirthdayPerson : string);
var
HappyBirthdayWords : TStringArray;
TheText : string;
I, J : Integer;
begin
HappyBirthdayWords := ['Happy ', 'Birthday ', 'To ', 'You '];
for J := 0 to 1 do
begin
for I := 0 to 3 do
TheText := TheText + HappyBirthdayWords[I];
WriteLn(TheText);
TheText := '';
end;
for I := 0 to 2 do
TheText := TheText + HappyBirthdayWords[I];
TheText := TheText + BirthdayPerson;
WriteLn(TheText);
TheText := '';
for I := 0 to 3 do
TheText := TheText + HappyBirthdayWords[I];
WriteLn(TheText);
WriteLn('Santy Loves ' + BirthdayPerson + '!');
end;
begin
ClearDebug;
GetSelf.WindowState := wsMinimized;
MainBirthdayFormShow;
GetSelf.WindowState := wsNormal;
if Sing then
SingHappyBirthday(BirthdayName);
end.