SRL Archive - Other Scripts

Random fact generator


Awkwardsaw

2009-09-18 07:38:57

i was bored, and i figured this would keep me some-what busy(using it, lol)

so, here i am presenting you 2-min of work, for you to laugh at, and hopefully be entertained :)

also, i would like a better way to get the text off of the page, since there is a lot of un-nessesary spaces for the chuck and mr t facts

program New;

var
// Initform variables.
frmDesign : TForm;
GroupBox1 : TGroupBox;
RadioButton1, RadioButton2, RadioButton3 : TRadioButton;
Memo1 : TMemo;
Button1 : TButton;

// This form was parsed using DFM Form Parser v.26c Beta by Ron.
// Generated from FactGenerator.dfm.

function GetFact(site, s1, s2: string): string;
var a: string;
begin
a:= getpage(site);
result:= TrimEx(' ', between(s1, s2, a));
end;

procedure StartClick(sender: TObject);
begin
if RadioButton1.Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=chuck', '<div id="factbox">', '</div>');
if RadioButton2.Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=mrt', '<div id="factbox">', '</div>');
if RadioButton3.Checked then
Memo1.Text:= GetFact('http://www.randomfunfacts.com/',
'<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong><i>', '</i></strong></font>');
end;

procedure Initform;
var
TimeInitform : Integer;
begin
TimeInitform := GetSystemTime;
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
Width := 365;
Height := 183;
Caption := 'Akwardsaw'#39's Fact Generator';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
GroupBox1 := TGroupBox.Create(frmDesign);
with GroupBox1 do
begin
Parent := frmDesign;
Left := 8;
Top := 8;
Width := 97;
Height := 89;
Caption := 'What Fact?';
TabOrder := 0;
end;
RadioButton1 := TRadioButton.Create(GroupBox1);
with RadioButton1 do
begin
Parent := GroupBox1;
Left := 8;
Top := 16;
Width := 113;
Height := 17;
Caption := 'Chuck Norris';
TabOrder := 0;
end;
RadioButton2 := TRadioButton.Create(GroupBox1);
with RadioButton2 do
begin
Parent := GroupBox1;
Left := 8;
Top := 40;
Width := 113;
Height := 17;
Caption := 'Mr. T';
TabOrder := 1;
end;
RadioButton3 := TRadioButton.Create(GroupBox1);
with RadioButton3 do
begin
Parent := GroupBox1;
Left := 8;
Top := 64;
Width := 113;
Height := 17;
Caption := 'Random';
TabOrder := 2;
end;
Memo1 := TMemo.Create(frmDesign);
with Memo1 do
begin
Parent := frmDesign;
Left := 112;
Top := 16;
Width := 225;
Height := 81;
with Lines do
begin
Add('');
end;
TabOrder := 9;
ScrollBars := ssVertical;
end;
Button1 := TButton.Create(frmDesign);
with Button1 do
begin
Parent := frmDesign;
Left := 96;
Top := 112;
Width := 73;
Height := 25;
Caption := 'Generate';
TabOrder := 10;
Button1.OnClick := @StartClick;
end;
WriteLn('Initform compiled in ' + IntToStr(GetSystemTime - TimeInitform) + ' milliseconds!');
end;

procedure SafeInitform;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('Initform', v);
end;

procedure ShowInitformModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowInitformModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowInitformModal', v);
end;

procedure MainInitform;
begin
try
SafeInitform;
SafeShowInitformModal;
finally
FreeForm(frmDesign);
except
WriteLn('An error seems to have occurred in: Initform');
end;
end;

begin
ClearDebug;
MainInitform;
end.

Gu3st...

2009-09-18 16:17:52

In a moment that will forever live in poker history, Chuck Norris forced Chris Moneymaker, Greg Raymer, and Joe Hachem to fold their hands after all three had already moved all in, by

That's one fact I got :P
Maybe you should make a scroll bar to the memo? :)

Awkwardsaw

2009-09-19 05:06:24

From: Zyt3x
That's one fact I got :P
Maybe you should make a scroll bar to the memo? :)


hmm, i didnt know the facts would be that big, shouldnt be to much of a problem to fix :)

edit: changed it now

Dan Cardin

2009-09-20 06:17:40

Im sorry.
var
frmDesign : TForm;
GroupBox1 : TGroupBox;
RadioButton: array [0..2] of TRadioButton;
Memo1 : TMemo;
Button1 : TButton;

function GetFact(site, s1, s2: string): string;
var a: string;
begin
a:= getpage(site);
result:= TrimEx(' ', between(s1, s2, a));
end;

procedure StartClick(sender: TObject);
begin
if RadioButton[0].Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=chuck', '<div id="factbox">', '</div>');
if RadioButton[1].Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=mrt', '<div id="factbox">', '</div>');
if RadioButton[2].Checked then
Memo1.Text:= GetFact('http://www.randomfunfacts.com/',
'<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong><i>', '</i></strong></font>');
end;

procedure Initform;
var
i: Integer;
a: Tstringarray;
begin
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
Width := 365;
Height := 183;
Caption := 'Akwardsaw'#39's Fact Generator';
end;
GroupBox1 := TGroupBox.Create(frmDesign);
with GroupBox1 do
begin
Parent := frmDesign;
SetBounds(8,8,97,89);
Caption := 'What Fact?';
end;
a:= ['Chuck Norris', 'Mr. T','Random'];
for i := 0 to high(radiobutton) do
begin
RadioButton[i] := TRadioButton.Create(GroupBox1);
with RadioButton[i] do
begin
Parent := GroupBox1;
SetBounds(8,16 + i*(24),113,17);
Caption := a[i];
end;
end;
Memo1 := TMemo.Create(frmDesign);
with Memo1 do
begin
Parent := frmDesign;
SetBounds(112,16,225,81);
lines.Add('');
ScrollBars := ssVertical;
end;
Button1 := TButton.Create(frmDesign);
with Button1 do
begin
Parent := frmDesign;
SetBounds(96,112,73,25);
Caption := 'Generate';
Button1.OnClick := @StartClick;
end;
end;

procedure SafeInitform;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('Initform', v);
end;

procedure ShowInitformModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowInitformModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowInitformModal', v);
end;

procedure MainInitform;
begin
try
SafeInitform;
SafeShowInitformModal;
finally
FreeForm(frmDesign);
except
WriteLn('An error seems to have occurred in: Initform');
end;
end;

begin
ClearDebug;
MainInitform;
end.

Awkwardsaw

2009-09-21 03:28:42

From: Dan Cardin
Im sorry.
var
frmDesign : TForm;
GroupBox1 : TGroupBox;
RadioButton: array [0..2] of TRadioButton;
Memo1 : TMemo;
Button1 : TButton;

function GetFact(site, s1, s2: string): string;
var a: string;
begin
a:= getpage(site);
result:= TrimEx(' ', between(s1, s2, a));
end;

procedure StartClick(sender: TObject);
begin
if RadioButton[0].Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=chuck', '<div id="factbox">', '</div>');
if RadioButton[1].Checked then
Memo1.Text:= GetFact('http://4q.cc/index.php?pid=fact&person=mrt', '<div id="factbox">', '</div>');
if RadioButton[2].Checked then
Memo1.Text:= GetFact('http://www.randomfunfacts.com/',
'<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong><i>', '</i></strong></font>');
end;

procedure Initform;
var
i: Integer;
a: Tstringarray;
begin
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
Width := 365;
Height := 183;
Caption := 'Akwardsaw'#39's Fact Generator';
end;
GroupBox1 := TGroupBox.Create(frmDesign);
with GroupBox1 do
begin
Parent := frmDesign;
SetBounds(8,8,97,89);
Caption := 'What Fact?';
end;
a:= ['Chuck Norris', 'Mr. T','Random'];
for i := 0 to high(radiobutton) do
begin
RadioButton[i] := TRadioButton.Create(GroupBox1);
with RadioButton[i] do
begin
Parent := GroupBox1;
SetBounds(8,16 + i*(24),113,17);
Caption := a[i];
end;
end;
Memo1 := TMemo.Create(frmDesign);
with Memo1 do
begin
Parent := frmDesign;
SetBounds(112,16,225,81);
lines.Add('');
ScrollBars := ssVertical;
end;
Button1 := TButton.Create(frmDesign);
with Button1 do
begin
Parent := frmDesign;
SetBounds(96,112,73,25);
Caption := 'Generate';
Button1.OnClick := @StartClick;
end;
end;

procedure SafeInitform;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('Initform', v);
end;

procedure ShowInitformModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowInitformModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowInitformModal', v);
end;

procedure MainInitform;
begin
try
SafeInitform;
SafeShowInitformModal;
finally
FreeForm(frmDesign);
except
WriteLn('An error seems to have occurred in: Initform');
end;
end;

begin
ClearDebug;
MainInitform;
end.


wait, what did you change? :o

Dan Cardin

2009-09-21 03:58:31

i made it shorter through some nitpicking stuff. Like arrays of whatnot. I just dislike seeing a bunch of separate things when they all have mostly the same data.

Awkwardsaw

2009-09-21 04:00:02

From: Dan Cardin
i made it shorter through some nitpicking stuff. Like arrays of whatnot. I just dislike seeing a bunch of separate things when they all have mostly the same data.


oo mkay :)