SRL Archive - OSR Help

Form Questions -


RISK

2010-01-27 12:58:45

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:


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

Thanks in advance!

Sex

2010-01-27 13:05:37

From: Risk
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:
[LEFT]procedure Example(Sender : TObject);
begin
OpenWebPage('www.google.com');
end;
[/LEFT]


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.

RISK

2010-01-27 13:08:04

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

Sex

2010-01-27 13:33:33

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 :p.
If you want I can help you with your specific needs if you add me on MSN: [email]kyle@kyleis1337.info[/email].

RISK

2010-01-27 13:37:24

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

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

Thanks again for helping me with my questions.

Sex

2010-01-27 13:39:51

Ah, I can't sleep because if I do it will mess up my sleep schedule (it's currently 10am) :p. I will be sure to get some tonight.
You're welcome :).

RISK

2010-01-27 14:26:55

:p 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.

Sex

2010-01-27 14:32:35

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 :p.

RISK

2010-01-27 14:38:36

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

Sex

2010-01-27 14:56:46

Yes, that would be better. Add [email]me@kwollaston.com[/email] though. I'm making a new MSN.

RISK

2010-01-27 15:01:22

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

Sex

2010-01-27 15:05:08

I added you. Try restarting MSN.