Results 1 to 12 of 12

Thread: Form Questions -

  1. #1
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Form Questions -

    Hi everyone, this time I have a few questions about forms. Hope I can get them answered, thanks!

    Question 1:
    If I had 2 listbox's and I wanted it to where if ListBox1 Item1 is clicked, it will make ListBox2 display something. Kind of like



    So I want if 'Ranged' is selected, I want ListBox2 to display 'Safe Spotting' etc. Can I get an example code on how this would work? Thanks.

    Question 2:
    How would I make if something in ListBox1 is selected and a button is pressed like 'Run', then it would do something depending on what is selected in ListBox1? I asked this question before in another thread of mine, but I never truly figured it out. (I thought I did). I did not want to double post, so yeah. Any help, please? I need it specific.

    Question 3:
    When I try to make a button open a web page (like www.Google.com for this example), it will spit this error out at me:

    Access to host denied by user
    What am I doing wrong? Here's my procedure:

    SCAR Code:
    procedure Example(Sender : TObject);
      begin
        OpenWebPage('www.google.com');
      end;

    Thanks in advance!

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

    Default

    Quote Originally Posted by Risk View Post
    Hi everyone, this time I have a few questions about forms. Hope I can get them answered, thanks!

    Question 1:
    If I had 2 listbox's and I wanted it to where if ListBox1 Item1 is clicked, it will make ListBox2 display something. Kind of like



    So I want if 'Ranged' is selected, I want ListBox2 to display 'Safe Spotting' etc. Can I get an example code on how this would work? Thanks.

    Question 2:
    How would I make if something in ListBox1 is selected and a button is pressed like 'Run', then it would do something depending on what is selected in ListBox1? I asked this question before in another thread of mine, but I never truly figured it out. (I thought I did). I did not want to double post, so yeah. Any help, please? I need it specific.

    Question 3:
    When I try to make a button open a web page (like www.Google.com for this example), it will spit this error out at me:



    What am I doing wrong? Here's my procedure:

    Code:
    procedure Example(Sender : TObject);
    begin
    OpenWebPage('www.google.com');
    end;


    Thanks in advance!
    For question 3, you need to put http:// in front of the string. As for question 1/question 2, I'll write an example script. Give me a few minutes.
    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"

  3. #3
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Great, that fixed my 3rd question. Okay, thanks for writing an example script.

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

    Default

    SCAR Code:
    program New;

    var
      Form : TForm;
      ListBox1 : TListBox;
      ListBox2 : TListBox;
      Button1 : TButton;
      Mains : TStringArray;
      Subs : T2DStringArray;
      Sel : integer;
     
    procedure InitMenus;
    var
      i, ii, h : integer;
    begin
      Mains := ['Option 1', 'Option 2', 'Option 3'];
      h := high(Mains);
      SetArrayLength(Subs, h + 1);
      for i := 0 to h do
        for ii := 0 to 1 do
        begin
          SetArrayLength(Subs[i], 2);
          Subs[i][ii] := Format('Option %d - Suboption %d', [i + 1, ii + 1]);
        end;
    end;

    procedure DoAction(Sender : TObject);
    var
      i, h : integer;
    begin
      case Sender of
        Listbox1 :
        begin
          if Listbox1.ItemIndex <> Sel then
          begin
            Sel := Listbox1.ItemIndex;
            Listbox2.Clear;
            h := high(Subs[Sel]);
            for i := 0 to h do
              Listbox2.Items.Add(Subs[Sel][i]);
          end;
        end;
        Button1 :
        begin
          case Sel of
            0 : case Listbox2.ItemIndex of
                  0 : writeln('Option 1 Suboption 1');
                  1 : writeln('Option 1 Suboption 2');
                end;
            1 : case Listbox2.ItemIndex of
                  0 : writeln('Option 2 Suboption 1');
                  1 : writeln('Option 2 Suboption 2');
                end;
            2 : case Listbox2.ItemIndex of
                  0 : writeln('Option 3 Suboption 1');
                  1 : writeln('Option 3 Suboption 2');
                end;
          end;
        end;
      end;
    end;

    procedure InitForm;
    var
      i, h : integer;
    begin
      Form := CreateForm;
      Form.Left := 250;
      Form.Top := 114;
      Form.BorderStyle := bsToolWindow;
      Form.Caption := 'Example';
      Form.ClientHeight := 112;
      Form.ClientWidth := 191;
      Form.Color := clBtnFace;
      Form.Font.Color := clWindowText;
      Form.Font.Height := -11;
      Form.Font.Name := 'MS Sans Serif';
      Form.Font.Style := [];
      Form.Visible := False;
      Form.PixelsPerInch := 96;
      InitMenus;
      ListBox1 := TListBox.Create(Form);
      ListBox1.Parent := Form;
      ListBox1.Left := 8;
      ListBox1.Top := 8;
      ListBox1.Width := 49;
      ListBox1.Height := 73;
      ListBox1.ItemHeight := 13;
      h := high(Mains);
      for i := 0 to h do
        ListBox1.Items.Add(Mains[i]);
      ListBox1.OnClick := @DoAction;
      ListBox1.TabOrder := 8;
      ListBox1.Selected[0] := True;
      ListBox2 := TListBox.Create(Form);
      ListBox2.Parent := Form;
      ListBox2.Left := 64;
      ListBox2.Top := 8;
      ListBox2.Width := 121;
      ListBox2.Height := 73;
      ListBox2.ItemHeight := 13;
      ListBox2.Items.Add('Option 1 - Suboption 1');
      ListBox2.Items.Add('Option 1 - Suboption 2');
      ListBox2.TabOrder := 9;
      Button1 := TButton.Create(Form);
      Button1.Parent := Form;
      Button1.Left := 8;
      Button1.Top := 88;
      Button1.Width := 88;
      Button1.Height := 20;
      Button1.Caption := 'Run';
      Button1.TabOrder := 10;
      Button1.OnClick := @DoAction;
    end;

    procedure SafeInitForm;
    var
      v : TVariantArray;
    begin
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      Form.ShowModal;
    end;

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

    begin
      SafeInitForm;
      SafeShowFormModal;
    end.
    It's really shitty I haven't slept at all for two days .
    If you want I can help you with your specific needs if you add me on MSN: kyle@kyleis1337.info.
    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
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks a lot, Sex. Maybe you should sleep? Happy birthday, by the way.

    I'll add you later, thanks for the offer!

    Thanks again for helping me with my questions.

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

    Default

    Ah, I can't sleep because if I do it will mess up my sleep schedule (it's currently 10am) . I will be sure to get some tonight.
    You're welcome .
    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"

  7. #7
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I hate staying up all night.

    Alright, I reviewed the script, thanks for making it. But can you make a 'mini-guide' on what to do for everything, please? Or can anyone? Weird to ask, but yeah. I really need to learn this for my first script I'm going to post in the First Script section.

    Thanks in advance.
    Last edited by RISK; 01-27-2010 at 07:30 PM.

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

    Default

    I really don't know how to explain it. I need to know exactly what you are trying to do so I can help you and explain what to do .
    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"

  9. #9
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Okay, that's easy enough:

    What I am trying to do is this, which you did in your example script, but I need to know what exactly you did, because I suck at just reading scripts like that. I need an explanation on the script.:

    I want Listbox1 to display 2 options:
    1. Melee
    2. Range

    When Range is clicked, I want it to display two options in ListBox2.
    1. Safe Spotting
    2. Collect Arrows

    Get me? I need to know how to do that. Kind of step by step, please. Any guide in the Tutorial section is major old ('07+) and incomplete. So, yeah.

    Maybe I should add you on MSN for better help/explanation? Lol. :l
    Last edited by RISK; 01-27-2010 at 07:41 PM.

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

    Default

    Yes, that would be better. Add me@kwollaston.com though. I'm making a new MSN.
    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"

  11. #11
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I can't add you because MSN is dumb on my computer. Can you add me, please?
    Riskug@gmail.com

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

    Default

    I added you. Try restarting MSN.
    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"

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
  •