Results 1 to 7 of 7

Thread: Random fact generator

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default Random fact generator

    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

    SCAR Code:
    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.
    Last edited by Awkwardsaw; 09-19-2009 at 09:15 AM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    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?

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    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
    Last edited by Awkwardsaw; 09-19-2009 at 09:14 AM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Im sorry.
    SCAR Code:
    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.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Dan Cardin View Post
    Im sorry.
    SCAR Code:
    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?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  6. #6
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    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.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  7. #7
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Dan Cardin View Post
    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
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •