Results 1 to 3 of 3

Thread: Form issue

  1. #1
    Join Date
    Mar 2009
    Location
    Illinois
    Posts
    292
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Form issue

    Hey guys I've been looking in to forms for the heck of it, and I can make the basics of a good form. But I've never attempted to implant runescape stuff into it. If that doesn't make since it will in a second. So I wrote up this real quick.
    SCAR Code:
    program Form;
    {.include srl/srl.scar}
    var
      Form: TForm;
      UsernameLb, PasswordLb: TLabel;
      UsernameE, PasswordE: TEdit;
      LoginBtn, ResetBtn: TButton;
    procedure ButtonClick(tob: TObject);
    begin
      case tob of
        LoginBtn: begin
                    Form.ModalResult:= mrOk;
                    Players[0].Name := UsernameE.text;
                    Players[0].Pass := PasswordE.text;
                    Players[0].Nick := 'null';
                    LoginPlayer;
                  end;
        ResetBtn: begin
                    UsernameE.Text := '';
                    PasswordE.Text := '';
                  end;
      end;
    end;
    procedure InitForm;
    begin
      Form := CreateForm;
      UsernameLb := TLabel.create(form);
      PasswordLb := TLabel.create(form);
      UsernameE := TEdit.create(form);
      PasswordE := TEdit.create(form);
      LoginBtn := TButton.create(form);
      ResetBtn := TButton.create(form);
     
      with Form do
      begin
        Left := 500;
        Top := 250;
        Height := 140;
        Width := 200;
        Caption := 'Auto Login';
        Color := clWhite;
      end;
      //LABELS
      with UsernameLb do
      begin
        Parent := Form;
        Left := 10;
        Top := 10;
        Caption := 'Username:';
      end;
      with PasswordLb do
      begin
        Parent := Form;
        Left := 10;
        Top := 50;
        Caption := 'Password:';
      end;
      //EDITBOXS
      with UsernameE do
      begin
        Parent := Form;
        Left := 75;
        Top := 10;
        Width := 100;
      end;
      with PasswordE do
      begin
        Parent := Form;
        Left := 75;
        Top := 50;
        Width := 100;
        PasswordChar := '*';
      end;
      //BUTTONS
      with LoginBtn do
      begin
        Parent := Form;
        Left := 10;
        Top := 80;
        Width := 75;
        Height := 20;
        Caption := 'Login';
        OnClick := @ButtonClick;
      end;
      with ResetBtn do
      begin
        Parent := Form;
        Left := 100;
        Top := 80;
        Width := 75;
        Height := 20;
        Caption := 'Reset';
        OnClick := @ButtonClick;
      end;
    end;
    procedure SafeInitForm;
    var
      V: Tvariantarray;
    begin
      setarraylength(v, 0);
      ThreadSafeCall('InitForm', v);
    end;
    procedure ShowFModal;
    begin
      Form.ShowModal;
    end;
    procedure SafeShowFModal;
    var
      V: Tvariantarray;
    begin
      setarraylength(v, 0);
      ThreadSafeCall('ShowFModal', v);
    end;
    begin
      SafeInitForm;
      SafeShowFModal;
    end.
    But, after typing in my username and password and clicking on the "Login" button creates this error:
    SCAR Code:
    [Runtime Error] : Out Of Range in line 106 in script
    Thats the "end;" on:
    SCAR Code:
    procedure ShowFModal;
    begin
      Form.ShowModal;
    end;


    Anyone know?

  2. #2
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    You need to set the length of Players[] with a DeclarePlayers procedure.

  3. #3
    Join Date
    Mar 2009
    Location
    Illinois
    Posts
    292
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    :facepalm: Thanks

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
  •