Results 1 to 6 of 6

Thread: Tabs on forms

  1. #1
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Tabs on forms

    I'm looking for a more code efficient way to make the same editbox on multiple tabs. Right now I have

    Code:
    Procedure Initform;
    begin
    FrmDesign := CreateForm;
    FrmDesign.Left := 333;
    FrmDesign.Top := 199;
    FrmDesign.Width := 386;
    FrmDesign.Height := 446;
    FrmDesign.Caption := 'FrmDesign';
    FrmDesign.Color := clBtnFace;
    FrmDesign.Font.Color := clWindowText;
    FrmDesign.Font.Height := -11;
    FrmDesign.Font.Name := 'MS Sans Serif';
    FrmDesign.Font.Style := [];
    FrmDesign.Visible := false;
    FrmDesign.PixelsPerInch := 96;
    PageControl := TPageControl.Create(FrmDesign);
    PageControl.Parent := FrmDesign;
    PageControl.Align := alClient;
    for i:= 1 to 5 do
    begin
      TabPages[i] := TTabSheet.create(frmdesign);
      TabPages[i].pagecontrol := PageControl;
      TabPages[i].Caption := 'Player ' + inttostr(i);
    Label1 := TLabel.Create(PageControl);
    Label1.Parent := TabPages[i];
    Label1.Left := 144;
    Label1.Top := 40;
    Label1.Width := 28;
    Label1.Height := 13;
    Label1.Caption := 'Name';
    Label2 := TLabel.Create(PageControl);
    Label2.Parent := TabPages[i];
    Label2.Left := 144;
    Label2.Top := 64;
    Label2.Width := 46;
    Label2.Height := 13;
    Label2.Caption := 'Password';
    Label3 := TLabel.Create(PageControl);
    Label3.Parent := TabPages[i];
    Label3.Left := 144;
    Label3.Top := 88;
    Label3.Width := 48;
    Label3.Height := 13;
    Label3.Caption := 'Nickname';
    Label4 := TLabel.Create(PageControl);
    Label4.Parent := TabPages[i];
    Label4.Left := 144;
    Label4.Top := 112;
    Label4.Width := 48;
    Label4.Height := 13;
    Label4.Caption := 'HoverSkill';
    Label8 := TLabel.Create(PageControl);
    Label8.Parent := TabPages[i];
    Label8.Left := 144;
    Label8.Top := 136;
    Label8.Width := 86;
    Label8.Height := 13;
    Label8.Caption := 'Time before break';
    Label10 := TLabel.Create(PageControl);
    Label10.Parent := TabPages[i];
    Label10.Left := 144;
    Label10.Top := 160;
    Label10.Width := 59;
    Label10.Height := 13;
    Label10.Caption := 'Loads to cut';
    Label11 := TLabel.Create(PageControl);
    Label11.Parent := TabPages[i];
    Label11.Left := 144;
    Label11.Top := 184;
    Label11.Width := 15;
    Label11.Height := 13;
    Label11.Caption := 'Pin';
    Label13 := TLabel.Create(PageControl);
    Label13.Parent := TabPages[i];
    Label13.Left := 16;
    Label13.Top := 8;
    Label13.Width := 345;
    Label13.Height := 22;
    Label13.Caption := 'Bbri06'#39's Catherby Yew Cutter and Banker';
    Label13.Font.Color := clGreen;
    Label13.Font.Height := -15;
    Label13.Font.Name := 'Arial Black';
    Label13.Font.Style := [];
    Memo1 := TMemo.Create(PageControl);
    Memo1.Parent := TabPages[i];
    Memo1.Left := 16;
    Memo1.Top := 224;
    Memo1.Width := 337;
    Memo1.Height := 137;
    Memo1.Lines.Add('    This script will cut and bank yew logs from the trees to the' +
      ' west of ');
    Memo1.Lines.Add('Catherby. It should be started amongst the grouping of trees. Yo' +
      'ur ');
    Memo1.Lines.Add('nickname should be 3-4 letters of your character'#39's name, HoverSk' +
      'ill ');
    Memo1.Lines.Add('should be one other than woodcutting as woodcutting is hovered o' +
      'ver ');
    Memo1.Lines.Add('already, and Time before break should be in minutes. If you don'#39 +
      't have ');
    Memo1.Lines.Add('a pin then leave that box blank.');
    Memo1.Lines.Add('');
    Memo1.Lines.Add('    Please post progress reports and errors on the scripts threa' +
      'd at ');
    Memo1.Lines.Add('www.villavu.com/forum.');
    Memo1.ReadOnly := True;
    Memo1.TabOrder := 15;
    end;
    NameBox := TEdit.Create(PageControl);
    NameBox.Parent := TabPages[1];
    NameBox.Left := 16;
    NameBox.Top := 40;
    NameBox.Width := 121;
    NameBox.Height := 21;
    NameBox.TabOrder := 8;
    PasswordBox := TEdit.Create(PageControl);
    PasswordBox.Parent := TabPages[1];
    PasswordBox.Left := 16;
    PasswordBox.Top := 64;
    PasswordBox.Width := 121;
    PasswordBox.Height := 21;
    PasswordBox.TabOrder := 9;
    NicknameBox := TEdit.Create(PageControl);
    NicknameBox.Parent := TabPages[1];
    NicknameBox.Left := 16;
    NicknameBox.Top := 88;
    NicknameBox.Width := 121;
    NicknameBox.Height := 21;
    NicknameBox.TabOrder := 10;
    HoverskillBox := TEdit.Create(PageControl);
    HoverskillBox.Parent := TabPages[1];
    HoverskillBox.Left := 16;
    HoverskillBox.Top := 112;
    HoverskillBox.Width := 121;
    HoverskillBox.Height := 21;
    HoverskillBox.TabOrder := 11;
    BreakBox := TEdit.Create(PageControl);
    BreakBox.Parent := TabPages[1];
    BreakBox.Left := 16;
    BreakBox.Top := 136;
    BreakBox.Width := 121;
    BreakBox.Height := 21;
    BreakBox.TabOrder := 12;
    LoadsBox := TEdit.Create(PageControl);
    LoadsBox.Parent := TabPages[1];
    LoadsBox.Left := 16;
    LoadsBox.Top := 160;
    LoadsBox.Width := 121;
    LoadsBox.Height := 21;
    LoadsBox.TabOrder := 13;
    PinBox := TEdit.Create(PageControl);
    PinBox.Parent := TabPages[1];
    PinBox.Left := 16;
    PinBox.Top := 184;
    PinBox.Width := 121;
    PinBox.Height := 21;
    PinBox.TabOrder := 14;
    ActiveBox := TCheckBox.Create(PageControl);
    ActiveBox.Parent := TabPages[1];
    ActiveBox.Left := 240;
    ActiveBox.Top := 40;
    ActiveBox.Width := 97;
    ActiveBox.Height := 60;
    ActiveBox.Caption := 'Active?';
    ActiveBox.TabOrder := 17;
    AxeBox := TCheckBox.Create(PageControl);
    AxeBox.Parent := TabPages[1];
    AxeBox.Left := 240;
    AxeBox.Top := 40;
    AxeBox.Width := 97;
    AxeBox.Height := 20;
    AxeBox.Caption := 'Wielding axe?';
    AxeBox.TabOrder := 17;
    NameBox2 := TEdit.Create(PageControl);
    NameBox2.Parent := TabPages[2];
    NameBox2.Left := 16;
    NameBox2.Top := 40;
    NameBox2.Width := 121;
    NameBox2.Height := 21;
    NameBox2.TabOrder := 8;
    PasswordBox2 := TEdit.Create(PageControl);
    PasswordBox2.Parent := TabPages[2];
    PasswordBox2.Left := 16;
    PasswordBox2.Top := 64;
    PasswordBox2.Width := 121;
    PasswordBox2.Height := 21;
    PasswordBox2.TabOrder := 9;
    NicknameBox2 := TEdit.Create(PageControl);
    NicknameBox2.Parent := TabPages[2];
    NicknameBox2.Left := 16;
    NicknameBox2.Top := 88;
    NicknameBox2.Width := 121;
    NicknameBox2.Height := 21;
    NicknameBox2.TabOrder := 10;
    HoverskillBox2 := TEdit.Create(PageControl);
    HoverskillBox2.Parent := TabPages[2];
    HoverskillBox2.Left := 16;
    HoverskillBox2.Top := 112;
    HoverskillBox2.Width := 121;
    HoverskillBox2.Height := 21;
    HoverskillBox2.TabOrder := 11;
    BreakBox2 := TEdit.Create(PageControl);
    BreakBox2.Parent := TabPages[2];
    BreakBox2.Left := 16;
    BreakBox2.Top := 136;
    BreakBox2.Width := 121;
    BreakBox2.Height := 21;
    BreakBox2.TabOrder := 12;
    LoadsBox2 := TEdit.Create(PageControl);
    LoadsBox2.Parent := TabPages[2];
    LoadsBox2.Left := 16;
    LoadsBox2.Top := 160;
    LoadsBox2.Width := 121;
    LoadsBox2.Height := 21;
    LoadsBox2.TabOrder := 13;
    PinBox2 := TEdit.Create(PageControl);
    PinBox2.Parent := TabPages[2];
    PinBox2.Left := 16;
    PinBox2.Top := 184;
    PinBox2.Width := 121;
    PinBox2.Height := 21;
    PinBox2.TabOrder := 14;
    ActiveBox2 := TCheckBox.Create(PageControl);
    ActiveBox2.Parent := TabPages[2];
    ActiveBox2.Left := 240;
    ActiveBox2.Top := 40;
    ActiveBox2.Width := 97;
    ActiveBox2.Height := 60;
    ActiveBox2.Caption := 'Active?';
    ActiveBox2.TabOrder := 17;
    AxeBox2 := TCheckBox.Create(PageControl);
    AxeBox2.Parent := TabPages[2];
    AxeBox2.Left := 240;
    AxeBox2.Top := 40;
    AxeBox2.Width := 97;
    AxeBox2.Height := 20;
    AxeBox2.Caption := 'Wielding axe?';
    AxeBox2.TabOrder := 17;
    end;
    I can put the labels in a for-to-do loop because they don't have to return certain values and can have all the same name. I found out when I try this with editboxes, the only box that returns a value is the last one.

  2. #2
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

    Default

    Could you include the varriables so it atleast compiles .

    3EDIT* just to let you know, there is a SRL Playerform which is a form you can run from your script which acts and declare players which is really good, so there is no point of making your own .

  3. #3
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Edit: Just read your edit and I'm slapping myself hard for spending all this time on this form lol.
    Edit2: Tried out SRLPlayerform and it just crashers scar every time the script starts. I did some searching and others were getting that error too.

    Here's the full form.
    Code:
    program New;
    var
      frmDesign : TForm;
      PageControl : TPageControl;
      TabPages: array[1..5]of TTabSheet;
      i: integer;
      Label1 : TLabel;
      Label2 : TLabel;
      Label3 : TLabel;
      Label4 : TLabel;
      Label8 : TLabel;
      Label10 : TLabel;
      Label11 : TLabel;
      Label13 : TLabel;
      NameBox : TEdit;
      PasswordBox : TEdit;
      NicknameBox : TEdit;
      HoverskillBox : TEdit;
      BreakBox : TEdit;
      LoadsBox : TEdit;
      PinBox : TEdit;
      Memo1 : TMemo;
      AxeBox : TCheckBox;
      ActiveBox : TCheckBox;
      NameBox2 : TEdit;
      PasswordBox2 : TEdit;
      NicknameBox2 : TEdit;
      HoverskillBox2 : TEdit;
      BreakBox2 : TEdit;
      LoadsBox2 : TEdit;
      PinBox2 : TEdit;
      AxeBox2 : TCheckBox;
      ActiveBox2 : TCheckBox;
      NameBox3 : TEdit;
      PasswordBox3 : TEdit;
      NicknameBox3 : TEdit;
      HoverskillBox3 : TEdit;
      BreakBox3 : TEdit;
      LoadsBox3 : TEdit;
      PinBox3 : TEdit;
      AxeBox3 : TCheckBox;
      ActiveBox3 : TCheckBox;
      NameBox4 : TEdit;
      PasswordBox4 : TEdit;
      NicknameBox4 : TEdit;
      HoverskillBox4 : TEdit;
      BreakBox4 : TEdit;
      LoadsBox4 : TEdit;
      PinBox4 : TEdit;
      AxeBox4 : TCheckBox;
      ActiveBox4 : TCheckBox;
      NameBox5 : TEdit;
      PasswordBox5 : TEdit;
      NicknameBox5 : TEdit;
      HoverskillBox5 : TEdit;
      BreakBox5 : TEdit;
      LoadsBox5 : TEdit;
      PinBox5 : TEdit;
      AxeBox5 : TCheckBox;
      ActiveBox5 : TCheckBox;
      StartButton : TButton;
      
    Procedure ButtonClick(Sender: TObject);
    Begin
      Writeln('Script started');
      FrmDesign.ModalResult := mrOk;
    End;
    
    Procedure Initform;
    begin
    FrmDesign := CreateForm;
    FrmDesign.Left := 333;
    FrmDesign.Top := 199;
    FrmDesign.Width := 386;
    FrmDesign.Height := 446;
    FrmDesign.Caption := 'FrmDesign';
    FrmDesign.Color := clBtnFace;
    FrmDesign.Font.Color := clWindowText;
    FrmDesign.Font.Height := -11;
    FrmDesign.Font.Name := 'MS Sans Serif';
    FrmDesign.Font.Style := [];
    FrmDesign.Visible := false;
    FrmDesign.PixelsPerInch := 96;
    PageControl := TPageControl.Create(FrmDesign);
    PageControl.Parent := FrmDesign;
    PageControl.Align := alClient;
    for i:= 1 to 5 do
    begin
      TabPages[i] := TTabSheet.create(frmdesign);
      TabPages[i].pagecontrol := PageControl;
      TabPages[i].Caption := 'Player ' + inttostr(i);
    Label1 := TLabel.Create(PageControl);
    Label1.Parent := TabPages[i];
    Label1.Left := 144;
    Label1.Top := 40;
    Label1.Width := 28;
    Label1.Height := 13;
    Label1.Caption := 'Name';
    Label2 := TLabel.Create(PageControl);
    Label2.Parent := TabPages[i];
    Label2.Left := 144;
    Label2.Top := 64;
    Label2.Width := 46;
    Label2.Height := 13;
    Label2.Caption := 'Password';
    Label3 := TLabel.Create(PageControl);
    Label3.Parent := TabPages[i];
    Label3.Left := 144;
    Label3.Top := 88;
    Label3.Width := 48;
    Label3.Height := 13;
    Label3.Caption := 'Nickname';
    Label4 := TLabel.Create(PageControl);
    Label4.Parent := TabPages[i];
    Label4.Left := 144;
    Label4.Top := 112;
    Label4.Width := 48;
    Label4.Height := 13;
    Label4.Caption := 'HoverSkill';
    Label8 := TLabel.Create(PageControl);
    Label8.Parent := TabPages[i];
    Label8.Left := 144;
    Label8.Top := 136;
    Label8.Width := 86;
    Label8.Height := 13;
    Label8.Caption := 'Time before break';
    Label10 := TLabel.Create(PageControl);
    Label10.Parent := TabPages[i];
    Label10.Left := 144;
    Label10.Top := 160;
    Label10.Width := 59;
    Label10.Height := 13;
    Label10.Caption := 'Loads to cut';
    Label11 := TLabel.Create(PageControl);
    Label11.Parent := TabPages[i];
    Label11.Left := 144;
    Label11.Top := 184;
    Label11.Width := 15;
    Label11.Height := 13;
    Label11.Caption := 'Pin';
    Label13 := TLabel.Create(PageControl);
    Label13.Parent := TabPages[i];
    Label13.Left := 16;
    Label13.Top := 8;
    Label13.Width := 345;
    Label13.Height := 22;
    Label13.Caption := 'Bbri06'#39's Catherby Yew Cutter and Banker';
    Label13.Font.Color := clGreen;
    Label13.Font.Height := -15;
    Label13.Font.Name := 'Arial Black';
    Label13.Font.Style := [];
    Memo1 := TMemo.Create(PageControl);
    Memo1.Parent := TabPages[i];
    Memo1.Left := 16;
    Memo1.Top := 224;
    Memo1.Width := 337;
    Memo1.Height := 137;
    Memo1.Lines.Add('    This script will cut and bank yew logs from the trees to the' +
      ' west of ');
    Memo1.Lines.Add('Catherby. It should be started amongst the grouping of trees. Yo' +
      'ur ');
    Memo1.Lines.Add('nickname should be 3-4 letters of your character'#39's name, HoverSk' +
      'ill ');
    Memo1.Lines.Add('should be one other than woodcutting as woodcutting is hovered o' +
      'ver ');
    Memo1.Lines.Add('already, and Time before break should be in minutes. If you don'#39 +
      't have ');
    Memo1.Lines.Add('a pin then leave that box blank.');
    Memo1.Lines.Add('');
    Memo1.Lines.Add('    Please post progress reports and errors on the scripts threa' +
      'd at ');
    Memo1.Lines.Add('www.villavu.com/forum.');
    Memo1.ReadOnly := True;
    Memo1.TabOrder := 15;
    end;
    NameBox := TEdit.Create(PageControl);
    NameBox.Parent := TabPages[1];
    NameBox.Left := 16;
    NameBox.Top := 40;
    NameBox.Width := 121;
    NameBox.Height := 21;
    NameBox.TabOrder := 8;
    PasswordBox := TEdit.Create(PageControl);
    PasswordBox.Parent := TabPages[1];
    PasswordBox.Left := 16;
    PasswordBox.Top := 64;
    PasswordBox.Width := 121;
    PasswordBox.Height := 21;
    PasswordBox.TabOrder := 9;
    NicknameBox := TEdit.Create(PageControl);
    NicknameBox.Parent := TabPages[1];
    NicknameBox.Left := 16;
    NicknameBox.Top := 88;
    NicknameBox.Width := 121;
    NicknameBox.Height := 21;
    NicknameBox.TabOrder := 10;
    HoverskillBox := TEdit.Create(PageControl);
    HoverskillBox.Parent := TabPages[1];
    HoverskillBox.Left := 16;
    HoverskillBox.Top := 112;
    HoverskillBox.Width := 121;
    HoverskillBox.Height := 21;
    HoverskillBox.TabOrder := 11;
    BreakBox := TEdit.Create(PageControl);
    BreakBox.Parent := TabPages[1];
    BreakBox.Left := 16;
    BreakBox.Top := 136;
    BreakBox.Width := 121;
    BreakBox.Height := 21;
    BreakBox.TabOrder := 12;
    LoadsBox := TEdit.Create(PageControl);
    LoadsBox.Parent := TabPages[1];
    LoadsBox.Left := 16;
    LoadsBox.Top := 160;
    LoadsBox.Width := 121;
    LoadsBox.Height := 21;
    LoadsBox.TabOrder := 13;
    PinBox := TEdit.Create(PageControl);
    PinBox.Parent := TabPages[1];
    PinBox.Left := 16;
    PinBox.Top := 184;
    PinBox.Width := 121;
    PinBox.Height := 21;
    PinBox.TabOrder := 14;
    ActiveBox := TCheckBox.Create(PageControl);
    ActiveBox.Parent := TabPages[1];
    ActiveBox.Left := 240;
    ActiveBox.Top := 40;
    ActiveBox.Width := 97;
    ActiveBox.Height := 60;
    ActiveBox.Caption := 'Active?';
    ActiveBox.TabOrder := 17;
    AxeBox := TCheckBox.Create(PageControl);
    AxeBox.Parent := TabPages[1];
    AxeBox.Left := 240;
    AxeBox.Top := 40;
    AxeBox.Width := 97;
    AxeBox.Height := 20;
    AxeBox.Caption := 'Wielding axe?';
    AxeBox.TabOrder := 17;
    NameBox2 := TEdit.Create(PageControl);
    NameBox2.Parent := TabPages[2];
    NameBox2.Left := 16;
    NameBox2.Top := 40;
    NameBox2.Width := 121;
    NameBox2.Height := 21;
    NameBox2.TabOrder := 8;
    PasswordBox2 := TEdit.Create(PageControl);
    PasswordBox2.Parent := TabPages[2];
    PasswordBox2.Left := 16;
    PasswordBox2.Top := 64;
    PasswordBox2.Width := 121;
    PasswordBox2.Height := 21;
    PasswordBox2.TabOrder := 9;
    NicknameBox2 := TEdit.Create(PageControl);
    NicknameBox2.Parent := TabPages[2];
    NicknameBox2.Left := 16;
    NicknameBox2.Top := 88;
    NicknameBox2.Width := 121;
    NicknameBox2.Height := 21;
    NicknameBox2.TabOrder := 10;
    HoverskillBox2 := TEdit.Create(PageControl);
    HoverskillBox2.Parent := TabPages[2];
    HoverskillBox2.Left := 16;
    HoverskillBox2.Top := 112;
    HoverskillBox2.Width := 121;
    HoverskillBox2.Height := 21;
    HoverskillBox2.TabOrder := 11;
    BreakBox2 := TEdit.Create(PageControl);
    BreakBox2.Parent := TabPages[2];
    BreakBox2.Left := 16;
    BreakBox2.Top := 136;
    BreakBox2.Width := 121;
    BreakBox2.Height := 21;
    BreakBox2.TabOrder := 12;
    LoadsBox2 := TEdit.Create(PageControl);
    LoadsBox2.Parent := TabPages[2];
    LoadsBox2.Left := 16;
    LoadsBox2.Top := 160;
    LoadsBox2.Width := 121;
    LoadsBox2.Height := 21;
    LoadsBox2.TabOrder := 13;
    PinBox2 := TEdit.Create(PageControl);
    PinBox2.Parent := TabPages[2];
    PinBox2.Left := 16;
    PinBox2.Top := 184;
    PinBox2.Width := 121;
    PinBox2.Height := 21;
    PinBox2.TabOrder := 14;
    ActiveBox2 := TCheckBox.Create(PageControl);
    ActiveBox2.Parent := TabPages[2];
    ActiveBox2.Left := 240;
    ActiveBox2.Top := 40;
    ActiveBox2.Width := 97;
    ActiveBox2.Height := 60;
    ActiveBox2.Caption := 'Active?';
    ActiveBox2.TabOrder := 17;
    AxeBox2 := TCheckBox.Create(PageControl);
    AxeBox2.Parent := TabPages[2];
    AxeBox2.Left := 240;
    AxeBox2.Top := 40;
    AxeBox2.Width := 97;
    AxeBox2.Height := 20;
    AxeBox2.Caption := 'Wielding axe?';
    AxeBox2.TabOrder := 17;
    NameBox3 := TEdit.Create(PageControl);
    NameBox3.Parent := TabPages[3];
    NameBox3.Left := 16;
    NameBox3.Top := 40;
    NameBox3.Width := 121;
    NameBox3.Height := 21;
    NameBox3.TabOrder := 8;
    PasswordBox3 := TEdit.Create(PageControl);
    PasswordBox3.Parent := TabPages[3];
    PasswordBox3.Left := 16;
    PasswordBox3.Top := 64;
    PasswordBox3.Width := 121;
    PasswordBox3.Height := 21;
    PasswordBox3.TabOrder := 9;
    NicknameBox3 := TEdit.Create(PageControl);
    NicknameBox3.Parent := TabPages[3];
    NicknameBox3.Left := 16;
    NicknameBox3.Top := 88;
    NicknameBox3.Width := 121;
    NicknameBox3.Height := 21;
    NicknameBox3.TabOrder := 10;
    HoverskillBox3 := TEdit.Create(PageControl);
    HoverskillBox3.Parent := TabPages[3];
    HoverskillBox3.Left := 16;
    HoverskillBox3.Top := 112;
    HoverskillBox3.Width := 121;
    HoverskillBox3.Height := 21;
    HoverskillBox3.TabOrder := 11;
    BreakBox3 := TEdit.Create(PageControl);
    BreakBox3.Parent := TabPages[3];
    BreakBox3.Left := 16;
    BreakBox3.Top := 136;
    BreakBox3.Width := 121;
    BreakBox3.Height := 21;
    BreakBox3.TabOrder := 12;
    LoadsBox3 := TEdit.Create(PageControl);
    LoadsBox3.Parent := TabPages[3];
    LoadsBox3.Left := 16;
    LoadsBox3.Top := 160;
    LoadsBox3.Width := 121;
    LoadsBox3.Height := 21;
    LoadsBox3.TabOrder := 13;
    PinBox3 := TEdit.Create(PageControl);
    PinBox3.Parent := TabPages[3];
    PinBox3.Left := 16;
    PinBox3.Top := 184;
    PinBox3.Width := 121;
    PinBox3.Height := 21;
    PinBox3.TabOrder := 14;
    ActiveBox3 := TCheckBox.Create(PageControl);
    ActiveBox3.Parent := TabPages[3];
    ActiveBox3.Left := 240;
    ActiveBox3.Top := 40;
    ActiveBox3.Width := 97;
    ActiveBox3.Height := 60;
    ActiveBox3.Caption := 'Active?';
    ActiveBox3.TabOrder := 17;
    AxeBox3 := TCheckBox.Create(PageControl);
    AxeBox3.Parent := TabPages[3];
    AxeBox3.Left := 240;
    AxeBox3.Top := 40;
    AxeBox3.Width := 97;
    AxeBox3.Height := 20;
    AxeBox3.Caption := 'Wielding axe?';
    AxeBox3.TabOrder := 17;
    NameBox4 := TEdit.Create(PageControl);
    NameBox4.Parent := TabPages[4];
    NameBox4.Left := 16;
    NameBox4.Top := 40;
    NameBox4.Width := 121;
    NameBox4.Height := 21;
    NameBox4.TabOrder := 8;
    PasswordBox4 := TEdit.Create(PageControl);
    PasswordBox4.Parent := TabPages[4];
    PasswordBox4.Left := 16;
    PasswordBox4.Top := 64;
    PasswordBox4.Width := 121;
    PasswordBox4.Height := 21;
    PasswordBox4.TabOrder := 9;
    NicknameBox4 := TEdit.Create(PageControl);
    NicknameBox4.Parent := TabPages[4];
    NicknameBox4.Left := 16;
    NicknameBox4.Top := 88;
    NicknameBox4.Width := 121;
    NicknameBox4.Height := 21;
    NicknameBox4.TabOrder := 10;
    HoverskillBox4 := TEdit.Create(PageControl);
    HoverskillBox4.Parent := TabPages[4];
    HoverskillBox4.Left := 16;
    HoverskillBox4.Top := 112;
    HoverskillBox4.Width := 121;
    HoverskillBox4.Height := 21;
    HoverskillBox4.TabOrder := 11;
    BreakBox4 := TEdit.Create(PageControl);
    BreakBox4.Parent := TabPages[4];
    BreakBox4.Left := 16;
    BreakBox4.Top := 136;
    BreakBox4.Width := 121;
    BreakBox4.Height := 21;
    BreakBox4.TabOrder := 12;
    LoadsBox4 := TEdit.Create(PageControl);
    LoadsBox4.Parent := TabPages[4];
    LoadsBox4.Left := 16;
    LoadsBox4.Top := 160;
    LoadsBox4.Width := 121;
    LoadsBox4.Height := 21;
    LoadsBox4.TabOrder := 13;
    PinBox4 := TEdit.Create(PageControl);
    PinBox4.Parent := TabPages[4];
    PinBox4.Left := 16;
    PinBox4.Top := 184;
    PinBox4.Width := 121;
    PinBox4.Height := 21;
    PinBox4.TabOrder := 14;
    ActiveBox4 := TCheckBox.Create(PageControl);
    ActiveBox4.Parent := TabPages[4];
    ActiveBox4.Left := 240;
    ActiveBox4.Top := 40;
    ActiveBox4.Width := 97;
    ActiveBox4.Height := 60;
    ActiveBox4.Caption := 'Active?';
    ActiveBox4.TabOrder := 17;
    AxeBox4 := TCheckBox.Create(PageControl);
    AxeBox4.Parent := TabPages[4];
    AxeBox4.Left := 240;
    AxeBox4.Top := 40;
    AxeBox4.Width := 97;
    AxeBox4.Height := 20;
    AxeBox4.Caption := 'Wielding axe?';
    AxeBox4.TabOrder := 17;
    NameBox5 := TEdit.Create(PageControl);
    NameBox5.Parent := TabPages[5];
    NameBox5.Left := 16;
    NameBox5.Top := 40;
    NameBox5.Width := 121;
    NameBox5.Height := 21;
    NameBox5.TabOrder := 8;
    PasswordBox5 := TEdit.Create(PageControl);
    PasswordBox5.Parent := TabPages[5];
    PasswordBox5.Left := 16;
    PasswordBox5.Top := 64;
    PasswordBox5.Width := 121;
    PasswordBox5.Height := 21;
    PasswordBox5.TabOrder := 9;
    NicknameBox5 := TEdit.Create(PageControl);
    NicknameBox5.Parent := TabPages[5];
    NicknameBox5.Left := 16;
    NicknameBox5.Top := 88;
    NicknameBox5.Width := 121;
    NicknameBox5.Height := 21;
    NicknameBox5.TabOrder := 10;
    HoverskillBox5 := TEdit.Create(PageControl);
    HoverskillBox5.Parent := TabPages[5];
    HoverskillBox5.Left := 16;
    HoverskillBox5.Top := 112;
    HoverskillBox5.Width := 121;
    HoverskillBox5.Height := 21;
    HoverskillBox5.TabOrder := 11;
    BreakBox5 := TEdit.Create(PageControl);
    BreakBox5.Parent := TabPages[5];
    BreakBox5.Left := 16;
    BreakBox5.Top := 136;
    BreakBox5.Width := 121;
    BreakBox5.Height := 21;
    BreakBox5.TabOrder := 12;
    LoadsBox5 := TEdit.Create(PageControl);
    LoadsBox5.Parent := TabPages[5];
    LoadsBox5.Left := 16;
    LoadsBox5.Top := 160;
    LoadsBox5.Width := 121;
    LoadsBox5.Height := 21;
    LoadsBox5.TabOrder := 13;
    PinBox5 := TEdit.Create(PageControl);
    PinBox5.Parent := TabPages[5];
    PinBox5.Left := 16;
    PinBox5.Top := 184;
    PinBox5.Width := 121;
    PinBox5.Height := 21;
    PinBox5.TabOrder := 14;
    ActiveBox5 := TCheckBox.Create(PageControl);
    ActiveBox5.Parent := TabPages[5];
    ActiveBox5.Left := 240;
    ActiveBox5.Top := 40;
    ActiveBox5.Width := 97;
    ActiveBox5.Height := 60;
    ActiveBox5.Caption := 'Active?';
    ActiveBox5.TabOrder := 17;
    AxeBox5 := TCheckBox.Create(PageControl);
    AxeBox5.Parent := TabPages[5];
    AxeBox5.Left := 240;
    AxeBox5.Top := 40;
    AxeBox5.Width := 97;
    AxeBox5.Height := 20;
    AxeBox5.Caption := 'Wielding axe?';
    AxeBox5.TabOrder := 17;
    StartButton := TButton.Create(PageControl);
    StartButton.Parent := TabPages[1];
    StartButton.Left := 240;
    StartButton.Top := 184;
    StartButton.Width := 75;
    StartButton.Height := 25;
    StartButton.Caption := 'Start';
    StartButton.TabOrder := 18;
    StartButton.OnClick := @ButtonClick;
    end;
    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;
    
    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;
    
    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;
    
    begin
      SafeInitForm;        // those 2 function are the action form setup. Thise one creates your form
      SafeShowFormModal;  // and this one makes it visible
    end.
    
    Procedure DeclarePlayers;
    var
      Active1, Active2, Active3, Active4, Active5: boolean;
      Axe1, Axe2, Axe3, Axe4, Axe5: boolean;
    begin
      NumberOfPlayers(5);
      CurrentPlayer := 0;
      if(ActiveBox.checked)then
      begin
        Active1 := true;
      end else
        Active1 := false;
      if(ActiveBox2.checked)then
      begin
        Active2 := true;
      end else
        Active2 := false;
      if(ActiveBox3.checked)then
      begin
        Active3 := true;
      end else
        Active3 := false;
      if(ActiveBox4.checked)then
      begin
        Active4 := true;
      end else
        Active4 := false;
      if(ActiveBox5.checked)then
      begin
        Active5 := true;
      end else
        Active5 := false;
      if(AxeBox.checked)then
      begin
        Axe1 := true;
      end else
        Axe1 := false;
      if(AxeBox2.checked)then
      begin
        Axe2 := true;
      end else
        Axe2 := false;
      if(AxeBox3.checked)then
      begin
        Axe3 := true;
      end else
        Axe3 := false;
      if(AxeBox4.checked)then
      begin
        Axe4 := true;
      end else
        Axe4 := false;
      if(AxeBox5.checked)then
      begin
        Axe5 := true;
      end else
        Axe5 := false;
      Players[0].Name        := NameBox.text;
      Players[0].Pass        := PasswordBox.text;
      Players[0].Nick        := NickNameBox.text;      // 3 or four letters form your character's name
      Players[0].Active      := Active1;
      Players[0].Booleans[0] := Axe1;       //true for wielding axe, false for in inventory
      Players[0].Strings[0]  := HoverSkillBox.text; // second skill to hover over
      Players[0].Integers[0] := StrToInt(BreakBox.text); //time in minutes before breaking, will have random time added
      Players[0].Integers[1] := StrToInt(LoadsBox.text); //Loads to cut before terminating
      Players[0].Strings[1] := PinBox.text; //Pin if you have one, leave blank if you don't have a pin
    
      Players[1].Name        := NameBox2.text;
      Players[1].Pass        := PasswordBox2.text;
      Players[1].Nick        := NicknameBox2.text;      // 3 or four letters form your character's name
      Players[1].Active      := Active2;
      Players[1].Booleans[0] := Axe2;       //true for wielding axe, false for in inventory
      Players[1].Strings[0]  := HoverSkillBox.text; // second skill to hover over
      Players[1].Integers[0] := StrToInt(BreakBox2.text); //time in minutes before breaking, will have random time added
      Players[1].Integers[1] := StrToInt(LoadsBox2.text); //Loads to cut before terminating
      Players[1].Strings[1] := PinBox2.text; //Pin if you have one, leave blank if you don't have a pin
    
      Players[2].Name        := NameBox3.text;
      Players[2].Pass        := PasswordBox3.text;
      Players[2].Nick        := NickNameBox3.text;      // 3 or four letters form your character's name
      Players[2].Active      := Active3;
      Players[2].Booleans[0] := Axe3;       //true for wielding axe, false for in inventory
      Players[2].Strings[0]  := HoverSkillBox3.text; // second skill to hover over
      Players[2].Integers[0] := StrToInt(BreakBox3.text); //time in minutes before breaking, will have random time added
      Players[2].Integers[1] := StrToInt(LoadsBox3.text); //Loads to cut before terminating
      Players[2].Strings[1] := PinBox3.text; //Pin if you have one, leave blank if you don't have a pin
    
      Players[3].Name        := NameBox4.text;
      Players[3].Pass        := PasswordBox4.text;
      Players[3].Nick        := NickNamebox4.text;      // 3 or four letters form your character's name
      Players[3].Active      := Active4;
      Players[3].Booleans[0] := Axe4;       //true for wielding axe, false for in inventory
      Players[3].Strings[0]  := HoverSkillBox4.text; // second skill to hover over
      Players[3].Integers[0] := StrToInt(BreakBox4.text); //time in minutes before breaking, will have random time added
      Players[3].Integers[1] := StrToInt(LoadsBox4.text); //Loads to cut before terminating
      Players[3].Strings[1] := PinBox4.text; //Pin if you have one, leave blank if you don't have a pin
      
      Players[4].Name        := NameBox5.text;
      Players[4].Pass        := PasswordBox5.text;
      Players[4].Nick        := NickNameBox5.text;      // 3 or four letters form your character's name
      Players[4].Active      := Active5;
      Players[4].Booleans[0] := Axe5;       //true for wielding axe, false for in inventory
      Players[4].Strings[0]  := HoverSkillBox5.text; // second skill to hover over
      Players[4].Integers[0] := StrToInt(BreakBox5.text); //time in minutes before breaking, will have random time added
      Players[4].Integers[1] := StrToInt(LoadsBox5.text); //Loads to cut before terminating
      Players[4].Strings[1] := PinBox5.text; //Pin if you have one, leave blank if you don't have a pin
    end;
    Last edited by bbri06; 12-26-2009 at 12:08 PM.

  4. #4
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You could optimize that by using arrays of TEdits and things like that.
    But I think you should just use SRL Player Form as BobboHobbo suggested.
    If you really want to make your own form, you can MSN me and I'll help you (just PM me and I'll give it to you).
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

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

    Default

    as a start i did this -
    SCAR Code:
    program New;
    var
      frmDesign : TForm;
      PageControl : TPageControl;
      TabPages: array[1..5]of TTabSheet;
      i: integer;
      Labels : array [0..7] of TLabel;
      NameBox : TEdit;
      PasswordBox : TEdit;
      NicknameBox : TEdit;
      HoverskillBox : TEdit;
      BreakBox : TEdit;
      LoadsBox : TEdit;
      PinBox : TEdit;
      Memo1 : TMemo;
      AxeBox : TCheckBox;
      ActiveBox : TCheckBox;
      NameBox2 : TEdit;
      PasswordBox2 : TEdit;
      NicknameBox2 : TEdit;
      HoverskillBox2 : TEdit;
      BreakBox2 : TEdit;
      LoadsBox2 : TEdit;
      PinBox2 : TEdit;
      AxeBox2 : TCheckBox;
      ActiveBox2 : TCheckBox;
      NameBox3 : TEdit;
      PasswordBox3 : TEdit;
      NicknameBox3 : TEdit;
      HoverskillBox3 : TEdit;
      BreakBox3 : TEdit;
      LoadsBox3 : TEdit;
      PinBox3 : TEdit;
      AxeBox3 : TCheckBox;
      ActiveBox3 : TCheckBox;
      NameBox4 : TEdit;
      PasswordBox4 : TEdit;
      NicknameBox4 : TEdit;
      HoverskillBox4 : TEdit;
      BreakBox4 : TEdit;
      LoadsBox4 : TEdit;
      PinBox4 : TEdit;
      AxeBox4 : TCheckBox;
      ActiveBox4 : TCheckBox;
      NameBox5 : TEdit;
      PasswordBox5 : TEdit;
      NicknameBox5 : TEdit;
      HoverskillBox5 : TEdit;
      BreakBox5 : TEdit;
      LoadsBox5 : TEdit;
      PinBox5 : TEdit;
      AxeBox5 : TCheckBox;
      ActiveBox5 : TCheckBox;
      StartButton : TButton;

    Procedure ButtonClick(Sender: TObject);
    Begin
      Writeln('Script started');
      FrmDesign.ModalResult := mrOk;
    End;

    Procedure Initform;
    var str: TStringArray;
    e: integer;
    begin
    FrmDesign := CreateForm;
    frmdesign.SetBounds(333,199,386,446);
    FrmDesign.Caption := 'FrmDesign';
    PageControl := TPageControl.Create(FrmDesign);
    PageControl.Parent := FrmDesign;
    PageControl.Align := alClient;
    for i:= 1 to 5 do
    begin
      TabPages[i] := TTabSheet.create(frmdesign);
      TabPages[i].pagecontrol := PageControl;
      TabPages[i].Caption := 'Player ' + inttostr(i);
    str := ['Name', 'Password','Nickname','HoverSkill','Time before break','Loads to cut','Pin','Bbri06'#39's Catherby Yew Cutter and Banker'];
    for e := 0 to 7 do
    begin
      Labels[e] := TLabel.Create(PageControl);
      Labels[e].Parent := TabPages[i];
      Labels[e].Left := 144;
      Labels[e].Top := 40 + e * 24;
      Labels[e].Width := 28;
      Labels[e].Height := 13;
      Labels[e].Caption := str[e];
    end;
    Memo1 := TMemo.Create(PageControl);
    Memo1.Parent := TabPages[i];
    memo1.SetBounds(16,224,337,137;
    memo1.WordWrap := true;
    Memo1.Lines.Add('    This script will cut and bank yew logs from the trees to the' +
      ' west of Catherby. It should be started amongst the grouping of trees. Yo' +
      'ur nickname should be 3-4 letters of your character'#39's name, HoverSk' +
      'ill should be one other than woodcutting as woodcutting is hovered o' +
      'ver already, and Time before break should be in minutes. If you don'#39 +
      't have a pin then leave that box blank.');
    Memo1.Lines.Add('');
    Memo1.Lines.Add('    Please post progress reports and errors on the scripts threa' +
      'd at ');
    Memo1.Lines.Add('www.villavu.com/forum.');
    Memo1.ReadOnly := True;
    end;
    NameBox := TEdit.Create(PageControl);
    NameBox.Parent := TabPages[1];
    NameBox.Left := 16;
    NameBox.Top := 40;
    NameBox.Width := 121;
    NameBox.Height := 21;
    NameBox.TabOrder := 8;
    PasswordBox := TEdit.Create(PageControl);
    PasswordBox.Parent := TabPages[1];
    PasswordBox.Left := 16;
    PasswordBox.Top := 64;
    PasswordBox.Width := 121;
    PasswordBox.Height := 21;
    PasswordBox.TabOrder := 9;
    NicknameBox := TEdit.Create(PageControl);
    NicknameBox.Parent := TabPages[1];
    NicknameBox.Left := 16;
    NicknameBox.Top := 88;
    NicknameBox.Width := 121;
    NicknameBox.Height := 21;
    NicknameBox.TabOrder := 10;
    HoverskillBox := TEdit.Create(PageControl);
    HoverskillBox.Parent := TabPages[1];
    HoverskillBox.Left := 16;
    HoverskillBox.Top := 112;
    HoverskillBox.Width := 121;
    HoverskillBox.Height := 21;
    HoverskillBox.TabOrder := 11;
    BreakBox := TEdit.Create(PageControl);
    BreakBox.Parent := TabPages[1];
    BreakBox.Left := 16;
    BreakBox.Top := 136;
    BreakBox.Width := 121;
    BreakBox.Height := 21;
    BreakBox.TabOrder := 12;
    LoadsBox := TEdit.Create(PageControl);
    LoadsBox.Parent := TabPages[1];
    LoadsBox.Left := 16;
    LoadsBox.Top := 160;
    LoadsBox.Width := 121;
    LoadsBox.Height := 21;
    LoadsBox.TabOrder := 13;
    PinBox := TEdit.Create(PageControl);
    PinBox.Parent := TabPages[1];
    PinBox.Left := 16;
    PinBox.Top := 184;
    PinBox.Width := 121;
    PinBox.Height := 21;
    PinBox.TabOrder := 14;
    ActiveBox := TCheckBox.Create(PageControl);
    ActiveBox.Parent := TabPages[1];
    ActiveBox.Left := 240;
    ActiveBox.Top := 40;
    ActiveBox.Width := 97;
    ActiveBox.Height := 60;
    ActiveBox.Caption := 'Active?';
    ActiveBox.TabOrder := 17;
    AxeBox := TCheckBox.Create(PageControl);
    AxeBox.Parent := TabPages[1];
    AxeBox.Left := 240;
    AxeBox.Top := 40;
    AxeBox.Width := 97;
    AxeBox.Height := 20;
    AxeBox.Caption := 'Wielding axe?';
    AxeBox.TabOrder := 17;
    NameBox2 := TEdit.Create(PageControl);
    NameBox2.Parent := TabPages[2];
    NameBox2.Left := 16;
    NameBox2.Top := 40;
    NameBox2.Width := 121;
    NameBox2.Height := 21;
    NameBox2.TabOrder := 8;
    PasswordBox2 := TEdit.Create(PageControl);
    PasswordBox2.Parent := TabPages[2];
    PasswordBox2.Left := 16;
    PasswordBox2.Top := 64;
    PasswordBox2.Width := 121;
    PasswordBox2.Height := 21;
    PasswordBox2.TabOrder := 9;
    NicknameBox2 := TEdit.Create(PageControl);
    NicknameBox2.Parent := TabPages[2];
    NicknameBox2.Left := 16;
    NicknameBox2.Top := 88;
    NicknameBox2.Width := 121;
    NicknameBox2.Height := 21;
    NicknameBox2.TabOrder := 10;
    HoverskillBox2 := TEdit.Create(PageControl);
    HoverskillBox2.Parent := TabPages[2];
    HoverskillBox2.Left := 16;
    HoverskillBox2.Top := 112;
    HoverskillBox2.Width := 121;
    HoverskillBox2.Height := 21;
    HoverskillBox2.TabOrder := 11;
    BreakBox2 := TEdit.Create(PageControl);
    BreakBox2.Parent := TabPages[2];
    BreakBox2.Left := 16;
    BreakBox2.Top := 136;
    BreakBox2.Width := 121;
    BreakBox2.Height := 21;
    BreakBox2.TabOrder := 12;
    LoadsBox2 := TEdit.Create(PageControl);
    LoadsBox2.Parent := TabPages[2];
    LoadsBox2.Left := 16;
    LoadsBox2.Top := 160;
    LoadsBox2.Width := 121;
    LoadsBox2.Height := 21;
    LoadsBox2.TabOrder := 13;
    PinBox2 := TEdit.Create(PageControl);
    PinBox2.Parent := TabPages[2];
    PinBox2.Left := 16;
    PinBox2.Top := 184;
    PinBox2.Width := 121;
    PinBox2.Height := 21;
    PinBox2.TabOrder := 14;
    ActiveBox2 := TCheckBox.Create(PageControl);
    ActiveBox2.Parent := TabPages[2];
    ActiveBox2.Left := 240;
    ActiveBox2.Top := 40;
    ActiveBox2.Width := 97;
    ActiveBox2.Height := 60;
    ActiveBox2.Caption := 'Active?';
    ActiveBox2.TabOrder := 17;
    AxeBox2 := TCheckBox.Create(PageControl);
    AxeBox2.Parent := TabPages[2];
    AxeBox2.Left := 240;
    AxeBox2.Top := 40;
    AxeBox2.Width := 97;
    AxeBox2.Height := 20;
    AxeBox2.Caption := 'Wielding axe?';
    AxeBox2.TabOrder := 17;
    NameBox3 := TEdit.Create(PageControl);
    NameBox3.Parent := TabPages[3];
    NameBox3.Left := 16;
    NameBox3.Top := 40;
    NameBox3.Width := 121;
    NameBox3.Height := 21;
    NameBox3.TabOrder := 8;
    PasswordBox3 := TEdit.Create(PageControl);
    PasswordBox3.Parent := TabPages[3];
    PasswordBox3.Left := 16;
    PasswordBox3.Top := 64;
    PasswordBox3.Width := 121;
    PasswordBox3.Height := 21;
    PasswordBox3.TabOrder := 9;
    NicknameBox3 := TEdit.Create(PageControl);
    NicknameBox3.Parent := TabPages[3];
    NicknameBox3.Left := 16;
    NicknameBox3.Top := 88;
    NicknameBox3.Width := 121;
    NicknameBox3.Height := 21;
    NicknameBox3.TabOrder := 10;
    HoverskillBox3 := TEdit.Create(PageControl);
    HoverskillBox3.Parent := TabPages[3];
    HoverskillBox3.Left := 16;
    HoverskillBox3.Top := 112;
    HoverskillBox3.Width := 121;
    HoverskillBox3.Height := 21;
    HoverskillBox3.TabOrder := 11;
    BreakBox3 := TEdit.Create(PageControl);
    BreakBox3.Parent := TabPages[3];
    BreakBox3.Left := 16;
    BreakBox3.Top := 136;
    BreakBox3.Width := 121;
    BreakBox3.Height := 21;
    BreakBox3.TabOrder := 12;
    LoadsBox3 := TEdit.Create(PageControl);
    LoadsBox3.Parent := TabPages[3];
    LoadsBox3.Left := 16;
    LoadsBox3.Top := 160;
    LoadsBox3.Width := 121;
    LoadsBox3.Height := 21;
    LoadsBox3.TabOrder := 13;
    PinBox3 := TEdit.Create(PageControl);
    PinBox3.Parent := TabPages[3];
    PinBox3.Left := 16;
    PinBox3.Top := 184;
    PinBox3.Width := 121;
    PinBox3.Height := 21;
    PinBox3.TabOrder := 14;
    ActiveBox3 := TCheckBox.Create(PageControl);
    ActiveBox3.Parent := TabPages[3];
    ActiveBox3.Left := 240;
    ActiveBox3.Top := 40;
    ActiveBox3.Width := 97;
    ActiveBox3.Height := 60;
    ActiveBox3.Caption := 'Active?';
    ActiveBox3.TabOrder := 17;
    AxeBox3 := TCheckBox.Create(PageControl);
    AxeBox3.Parent := TabPages[3];
    AxeBox3.Left := 240;
    AxeBox3.Top := 40;
    AxeBox3.Width := 97;
    AxeBox3.Height := 20;
    AxeBox3.Caption := 'Wielding axe?';
    AxeBox3.TabOrder := 17;
    NameBox4 := TEdit.Create(PageControl);
    NameBox4.Parent := TabPages[4];
    NameBox4.Left := 16;
    NameBox4.Top := 40;
    NameBox4.Width := 121;
    NameBox4.Height := 21;
    NameBox4.TabOrder := 8;
    PasswordBox4 := TEdit.Create(PageControl);
    PasswordBox4.Parent := TabPages[4];
    PasswordBox4.Left := 16;
    PasswordBox4.Top := 64;
    PasswordBox4.Width := 121;
    PasswordBox4.Height := 21;
    PasswordBox4.TabOrder := 9;
    NicknameBox4 := TEdit.Create(PageControl);
    NicknameBox4.Parent := TabPages[4];
    NicknameBox4.Left := 16;
    NicknameBox4.Top := 88;
    NicknameBox4.Width := 121;
    NicknameBox4.Height := 21;
    NicknameBox4.TabOrder := 10;
    HoverskillBox4 := TEdit.Create(PageControl);
    HoverskillBox4.Parent := TabPages[4];
    HoverskillBox4.Left := 16;
    HoverskillBox4.Top := 112;
    HoverskillBox4.Width := 121;
    HoverskillBox4.Height := 21;
    HoverskillBox4.TabOrder := 11;
    BreakBox4 := TEdit.Create(PageControl);
    BreakBox4.Parent := TabPages[4];
    BreakBox4.Left := 16;
    BreakBox4.Top := 136;
    BreakBox4.Width := 121;
    BreakBox4.Height := 21;
    BreakBox4.TabOrder := 12;
    LoadsBox4 := TEdit.Create(PageControl);
    LoadsBox4.Parent := TabPages[4];
    LoadsBox4.Left := 16;
    LoadsBox4.Top := 160;
    LoadsBox4.Width := 121;
    LoadsBox4.Height := 21;
    LoadsBox4.TabOrder := 13;
    PinBox4 := TEdit.Create(PageControl);
    PinBox4.Parent := TabPages[4];
    PinBox4.Left := 16;
    PinBox4.Top := 184;
    PinBox4.Width := 121;
    PinBox4.Height := 21;
    PinBox4.TabOrder := 14;
    ActiveBox4 := TCheckBox.Create(PageControl);
    ActiveBox4.Parent := TabPages[4];
    ActiveBox4.Left := 240;
    ActiveBox4.Top := 40;
    ActiveBox4.Width := 97;
    ActiveBox4.Height := 60;
    ActiveBox4.Caption := 'Active?';
    ActiveBox4.TabOrder := 17;
    AxeBox4 := TCheckBox.Create(PageControl);
    AxeBox4.Parent := TabPages[4];
    AxeBox4.Left := 240;
    AxeBox4.Top := 40;
    AxeBox4.Width := 97;
    AxeBox4.Height := 20;
    AxeBox4.Caption := 'Wielding axe?';
    AxeBox4.TabOrder := 17;
    NameBox5 := TEdit.Create(PageControl);
    NameBox5.Parent := TabPages[5];
    NameBox5.Left := 16;
    NameBox5.Top := 40;
    NameBox5.Width := 121;
    NameBox5.Height := 21;
    NameBox5.TabOrder := 8;
    PasswordBox5 := TEdit.Create(PageControl);
    PasswordBox5.Parent := TabPages[5];
    PasswordBox5.Left := 16;
    PasswordBox5.Top := 64;
    PasswordBox5.Width := 121;
    PasswordBox5.Height := 21;
    PasswordBox5.TabOrder := 9;
    NicknameBox5 := TEdit.Create(PageControl);
    NicknameBox5.Parent := TabPages[5];
    NicknameBox5.Left := 16;
    NicknameBox5.Top := 88;
    NicknameBox5.Width := 121;
    NicknameBox5.Height := 21;
    NicknameBox5.TabOrder := 10;
    HoverskillBox5 := TEdit.Create(PageControl);
    HoverskillBox5.Parent := TabPages[5];
    HoverskillBox5.Left := 16;
    HoverskillBox5.Top := 112;
    HoverskillBox5.Width := 121;
    HoverskillBox5.Height := 21;
    HoverskillBox5.TabOrder := 11;
    BreakBox5 := TEdit.Create(PageControl);
    BreakBox5.Parent := TabPages[5];
    BreakBox5.Left := 16;
    BreakBox5.Top := 136;
    BreakBox5.Width := 121;
    BreakBox5.Height := 21;
    BreakBox5.TabOrder := 12;
    LoadsBox5 := TEdit.Create(PageControl);
    LoadsBox5.Parent := TabPages[5];
    LoadsBox5.Left := 16;
    LoadsBox5.Top := 160;
    LoadsBox5.Width := 121;
    LoadsBox5.Height := 21;
    LoadsBox5.TabOrder := 13;
    PinBox5 := TEdit.Create(PageControl);
    PinBox5.Parent := TabPages[5];
    PinBox5.Left := 16;
    PinBox5.Top := 184;
    PinBox5.Width := 121;
    PinBox5.Height := 21;
    PinBox5.TabOrder := 14;
    ActiveBox5 := TCheckBox.Create(PageControl);
    ActiveBox5.Parent := TabPages[5];
    ActiveBox5.Left := 240;
    ActiveBox5.Top := 40;
    ActiveBox5.Width := 97;
    ActiveBox5.Height := 60;
    ActiveBox5.Caption := 'Active?';
    ActiveBox5.TabOrder := 17;
    AxeBox5 := TCheckBox.Create(PageControl);
    AxeBox5.Parent := TabPages[5];
    AxeBox5.Left := 240;
    AxeBox5.Top := 40;
    AxeBox5.Width := 97;
    AxeBox5.Height := 20;
    AxeBox5.Caption := 'Wielding axe?';
    AxeBox5.TabOrder := 17;
    StartButton := TButton.Create(PageControl);
    StartButton.Parent := TabPages[1];
    StartButton.Left := 240;
    StartButton.Top := 184;
    StartButton.Width := 75;
    StartButton.Height := 25;
    StartButton.Caption := 'Start';
    StartButton.TabOrder := 18;
    StartButton.OnClick := @ButtonClick;
    end;
    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    begin
      SafeInitForm;        // those 2 function are the action form setup. Thise one creates your form
      SafeShowFormModal;  // and this one makes it visible
    end.

    Procedure DeclarePlayers;
    var
      Active1, Active2, Active3, Active4, Active5: boolean;
      Axe1, Axe2, Axe3, Axe4, Axe5: boolean;
    begin
      NumberOfPlayers(5);
      CurrentPlayer := 0;
      if(ActiveBox.checked)then
      begin
        Active1 := true;
      end else
        Active1 := false;
      if(ActiveBox2.checked)then
      begin
        Active2 := true;
      end else
        Active2 := false;
      if(ActiveBox3.checked)then
      begin
        Active3 := true;
      end else
        Active3 := false;
      if(ActiveBox4.checked)then
      begin
        Active4 := true;
      end else
        Active4 := false;
      if(ActiveBox5.checked)then
      begin
        Active5 := true;
      end else
        Active5 := false;
      if(AxeBox.checked)then
      begin
        Axe1 := true;
      end else
        Axe1 := false;
      if(AxeBox2.checked)then
      begin
        Axe2 := true;
      end else
        Axe2 := false;
      if(AxeBox3.checked)then
      begin
        Axe3 := true;
      end else
        Axe3 := false;
      if(AxeBox4.checked)then
      begin
        Axe4 := true;
      end else
        Axe4 := false;
      if(AxeBox5.checked)then
      begin
        Axe5 := true;
      end else
        Axe5 := false;
      Players[0].Name        := NameBox.text;
      Players[0].Pass        := PasswordBox.text;
      Players[0].Nick        := NickNameBox.text;      // 3 or four letters form your character's name
      Players[0].Active      := Active1;
      Players[0].Booleans[0] := Axe1;       //true for wielding axe, false for in inventory
      Players[0].Strings[0]  := HoverSkillBox.text; // second skill to hover over
      Players[0].Integers[0] := StrToInt(BreakBox.text); //time in minutes before breaking, will have random time added
      Players[0].Integers[1] := StrToInt(LoadsBox.text); //Loads to cut before terminating
      Players[0].Strings[1] := PinBox.text; //Pin if you have one, leave blank if you don't have a pin

      Players[1].Name        := NameBox2.text;
      Players[1].Pass        := PasswordBox2.text;
      Players[1].Nick        := NicknameBox2.text;      // 3 or four letters form your character's name
      Players[1].Active      := Active2;
      Players[1].Booleans[0] := Axe2;       //true for wielding axe, false for in inventory
      Players[1].Strings[0]  := HoverSkillBox.text; // second skill to hover over
      Players[1].Integers[0] := StrToInt(BreakBox2.text); //time in minutes before breaking, will have random time added
      Players[1].Integers[1] := StrToInt(LoadsBox2.text); //Loads to cut before terminating
      Players[1].Strings[1] := PinBox2.text; //Pin if you have one, leave blank if you don't have a pin

      Players[2].Name        := NameBox3.text;
      Players[2].Pass        := PasswordBox3.text;
      Players[2].Nick        := NickNameBox3.text;      // 3 or four letters form your character's name
      Players[2].Active      := Active3;
      Players[2].Booleans[0] := Axe3;       //true for wielding axe, false for in inventory
      Players[2].Strings[0]  := HoverSkillBox3.text; // second skill to hover over
      Players[2].Integers[0] := StrToInt(BreakBox3.text); //time in minutes before breaking, will have random time added
      Players[2].Integers[1] := StrToInt(LoadsBox3.text); //Loads to cut before terminating
      Players[2].Strings[1] := PinBox3.text; //Pin if you have one, leave blank if you don't have a pin

      Players[3].Name        := NameBox4.text;
      Players[3].Pass        := PasswordBox4.text;
      Players[3].Nick        := NickNamebox4.text;      // 3 or four letters form your character's name
      Players[3].Active      := Active4;
      Players[3].Booleans[0] := Axe4;       //true for wielding axe, false for in inventory
      Players[3].Strings[0]  := HoverSkillBox4.text; // second skill to hover over
      Players[3].Integers[0] := StrToInt(BreakBox4.text); //time in minutes before breaking, will have random time added
      Players[3].Integers[1] := StrToInt(LoadsBox4.text); //Loads to cut before terminating
      Players[3].Strings[1] := PinBox4.text; //Pin if you have one, leave blank if you don't have a pin

      Players[4].Name        := NameBox5.text;
      Players[4].Pass        := PasswordBox5.text;
      Players[4].Nick        := NickNameBox5.text;      // 3 or four letters form your character's name
      Players[4].Active      := Active5;
      Players[4].Booleans[0] := Axe5;       //true for wielding axe, false for in inventory
      Players[4].Strings[0]  := HoverSkillBox5.text; // second skill to hover over
      Players[4].Integers[0] := StrToInt(BreakBox5.text); //time in minutes before breaking, will have random time added
      Players[4].Integers[1] := StrToInt(LoadsBox5.text); //Loads to cut before terminating
      Players[4].Strings[1] := PinBox5.text; //Pin if you have one, leave blank if you don't have a pin
    end;
    thats only changing a few things. It can indeed be much more efficient than this.

    EDIT: did more -
    SCAR Code:
    program New;
    var
      frmDesign : TForm;
      PageControl : TTabControl;
      Labels : array of TLabel;
      edits: array of TEdit;
      Memo1 : TMemo;
      AxeBox : TCheckBox;
      ActiveBox : TCheckBox;
      StartButton : TButton;
      fullArr: Array of TStringArray;

    Procedure ButtonClick(Sender: TObject);
    Begin
      Writeln('Script started');
      FrmDesign.ModalResult := mrOk;
    End;

    procedure ChangeEdits(Sender: Tobject);
    var i : integer;
    begin
      for i := 0 to high(edits) do
        edits[i].text := fullArr[pagecontrol.TabIndex][i];
      ActiveBox.Checked := strtobool(fullArr[pagecontrol.TabIndex][high(fullArr[pagecontrol.TabIndex]) - 1]);
      AxeBox.Checked := strtobool(fullArr[pagecontrol.TabIndex][high(fullArr[pagecontrol.TabIndex])]);
    end;

    procedure Changing(Sender: TObject; var AllowChange: Boolean);
    var i : integer;
    begin
      for i := 0 to high(edits) do
        fullArr[pagecontrol.TabIndex][i] := edits[i].text;
      fullArr[pagecontrol.TabIndex][high(fullArr[0]) - 1] := booltostr(ActiveBox.Checked);
      fullArr[pagecontrol.TabIndex][high(fullArr[0])] := booltostr(AxeBox.Checked);
    end;

    Procedure Initform;
    var str: TStringArray;
    i,e: integer;
    begin
      str := ['Name', 'Password','Nickname','HoverSkill','Time before break','Loads to cut','Pin'];
      FrmDesign := CreateForm;
      frmdesign.SetBounds(333,199,386,446);
      FrmDesign.Caption := 'Bbri06'#39's Catherby Yew Cutter and Banker';
      frmdesign.AutoScroll := false;
      PageControl := TTabControl.Create(FrmDesign);
      PageControl.Parent := FrmDesign;
      PageControl.SetBounds(0, 0, frmDesign.Width, 21);
      PageControl.OnChange := @ChangeEdits;
      PageControl.OnChanging := @Changing;

      SetArrayLength(fullarr, 6);
      for i := 0 to high(fullarr) do
      begin
        SetArrayLength(fullarr[i], GetArrayLength(str) + 2);
        PageControl.tabs.Append('Player' + inttostr(i + 1));
        fullarr[i][7] := 'False';
        fullarr[i][8] := 'False';
      end;
      SetArrayLength(Labels, GetArrayLength(str));
      for e := 0 to high(str) do
      begin
        Labels[e] := TLabel.Create(PageControl);
        Labels[e].Parent := frmdesign;
        Labels[e].Left := 144;
        Labels[e].Top := 40 + e * 24;
        Labels[e].Width := 28;
        Labels[e].Height := 13;
        Labels[e].Caption := str[e];
      end;
      Memo1 := TMemo.Create(PageControl);
      Memo1.Parent := frmdesign;
      memo1.SetBounds(16,224,337,137);
      memo1.WordWrap := true;
      Memo1.Lines.Add('    This script will cut and bank yew logs from the trees to the' +
        ' west of Catherby. It should be started amongst the grouping of trees. Yo' +
        'ur nickname should be 3-4 letters of your character'#39's name, HoverSk' +
        'ill should be one other than woodcutting as woodcutting is hovered o' +
        'ver already, and Time before break should be in minutes. If you don'#39 +
        't have a pin then leave that box blank.' + #13#10+ #13#10 + '    Please post progress reports and errors on the scripts threa' +
        'd at ' + #13#10 + 'www.villavu.com/forum.');
      Memo1.ReadOnly := True;

      SetArrayLength(edits, 7);
      for i := 0 to high(edits) do
      begin
        edits[i] := TEdit.Create(PageControl);
        edits[i].Parent := frmdesign;
        edits[i].SetBounds(16,40 + 24 * i,121,21);
      end;


      ActiveBox := TCheckBox.Create(PageControl);
      ActiveBox.Parent := frmdesign;
      ActiveBox.SetBounds(240,40,97,60);
      ActiveBox.Caption := 'Active?';
      AxeBox := TCheckBox.Create(PageControl);
      AxeBox.Parent := frmdesign;
      AxeBox.SetBounds(240,40,97,20);
      AxeBox.Caption := 'Wielding axe?';
     
      StartButton := TButton.Create(PageControl);
      StartButton.Parent := frmdesign;
      StartButton.SetBounds(240,184,75,25);
      StartButton.Caption := 'Start';
      StartButton.OnClick := @ButtonClick;
    end;
    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    begin
      SafeInitForm;        // those 2 function are the action form setup. Thise one creates your form
      SafeShowFormModal;  // and this one makes it visible
    end.

    Procedure DeclarePlayers;
    var i: integer;
    begin
      NumberOfPlayers(GetArrayLength(fullarr));
      CurrentPlayer := 0;
      for i := 0 to high(fullArr) do
      begin
        Players[i].Name        := fullarr[i][0].text;
        Players[i].Pass        := fullarr[i][1].text;
        Players[i].Nick        := fullarr[i][2].text;      // 3 or four letters form your character's name
        Players[i].Active      := fullarr[i][9]
        Players[i].Booleans[0] := fullarr[i][8];       //true for wielding axe, false for in inventory
        Players[i].Strings[0]  := fullarr[i][3].text; // second skill to hover over
        Players[i].Integers[0] := StrToInt(fullarr[i][4].text); //time in minutes before breaking, will have random time added
        Players[i].Integers[1] := StrToInt(fullarr[i][5].text); //Loads to cut before terminating
        Players[i].Strings[1] := fullarr[i][6].text; //Pin if you have one, leave blank if you don't have a pin
      end;
    end;
    Last edited by Dan Cardin; 12-26-2009 at 05:05 PM.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  6. #6
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for that, was what I was looking for.

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
  •