SRL Archive - OSR Help

Working on a form.


Wyn

2011-11-04 23:55:40

Trying to get back into Srl through re-writing scripts I used and loved back then…

I am though having trouble with forms receiving error's such as Error in InitForm! and Error: Out Of Range at line 1548 and was wondering if someone could help me get back into the groove.

I plan on Applying for srl very soon :D.


Here is how I do the form…Error lines will be commented…

Procedure SafeInitForm; //How I start the form
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end; //Out of range here

procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;

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


The actual form itself; it says there's a error in it, I can't figure out what it is…:

Procedure InitForm;
Begin
LoadUs2;
frmDesign := CreateForm;
frmDesign.Position := poDesktopCenter;
frmDesign.Width := 313;
frmDesign.Height := 285;
frmDesign.Caption := 'Caption';
frmDesign.Color := clInactiveCaption;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
frmDesign.OnCloseQuery := @FormClose2;

TitleLabel := TLabel.Create(frmDesign);
TitleLabel.Parent := frmDesign;
TitleLabel.Left := 28;
TitleLabel.Top := 10;
TitleLabel.Width := 277;
TitleLabel.Height := 20;
TitleLabel.Caption := 'Caption';
TitleLabel.Font.Color := clWindowText;
TitleLabel.Font.Height := -17;
TitleLabel.Font.Name := 'MS Sans Serif';
TitleLabel.Font.Style := [fsBold, fsUnderline];
TitleLabel.ParentFont := False;

CreatePlayerButton := TButton.Create(frmDesign);
CreatePlayerButton.Parent := frmDesign;
CreatePlayerButton.Left := 60;
CreatePlayerButton.Top := 35;
CreatePlayerButton.Width := 83;
CreatePlayerButton.Height := 29;
CreatePlayerButton.Hint := 'Click to Create a New Player';
CreatePlayerButton.Caption := 'Create Player';
CreatePlayerButton.ParentShowHint := False;
CreatePlayerButton.ShowHint := True;
CreatePlayerButton.TabOrder := 13;
CreatePlayerButton.OnClick := @CreateNewUser;

DeletePlayerButton := TButton.Create(frmDesign);
DeletePlayerButton.Parent := frmDesign;
DeletePlayerButton.Left := 150;
DeletePlayerButton.Top := 35;
DeletePlayerButton.Width := 83;
DeletePlayerButton.Height := 29;
DeletePlayerButton.Hint := 'Click to Delete the Current Player';
DeletePlayerButton.Caption := 'Delete Player';
DeletePlayerButton.ParentShowHint := False;
DeletePlayerButton.ShowHint := True;
DeletePlayerButton.TabOrder := 13;
DeletePlayerButton.OnClick := @DeleteAPlayer;

LeftButton := TButton.Create(frmDesign);
LeftButton.Parent := frmDesign;
LeftButton.Left := 15;
LeftButton.Top := 35;
LeftButton.Width := 38;
LeftButton.Height := 29;
LeftButton.Hint := 'Click to go to the Previous Player';
LeftButton.Caption := '<---';
LeftButton.ParentShowHint := False;
LeftButton.ShowHint := True;
LeftButton.TabOrder := 13;
LeftButton.OnClick := @PressBackButton;

RightButton := TButton.Create(frmDesign);
RightButton.Parent := frmDesign;
RightButton.Left := 239;
RightButton.Top := 35;
RightButton.Width := 38;
RightButton.Height := 29;
RightButton.Hint := 'Click to go to the Next Player';
RightButton.Caption := '--->';
RightButton.ParentShowHint := False;
RightButton.ShowHint := True;
RightButton.TabOrder := 14;
RightButton.OnClick := @PressNextButton;

UsernameLabel := TLabel.Create(frmDesign);
UsernameLabel.Parent := frmDesign;
UsernameLabel.Left := 16;
UsernameLabel.Top := 73;
UsernameLabel.Width := 63;
UsernameLabel.Height := 16;
UsernameLabel.Font.Color := clWindowText;
UsernameLabel.Font.Height := -15;
UsernameLabel.Font.Name := 'MS Sans Serif';
UsernameLabel.Font.Style := [];
UsernameLabel.ParentFont := False;
UsernameLabel.Caption := '0. Username';

PasswordLabel := TLabel.Create(frmDesign);
PasswordLabel.Parent := frmDesign;
PasswordLabel.Left := 16;
PasswordLabel.Top := 96;
PasswordLabel.Width := 60;
PasswordLabel.Height := 16;
PasswordLabel.Font.Color := clWindowText;
PasswordLabel.Font.Height := -15;
PasswordLabel.Font.Name := 'MS Sans Serif';
PasswordLabel.Font.Style := [];
PasswordLabel.ParentFont := False;
PasswordLabel.Caption := '0. Password';

LampSkillLabel := TLabel.Create(frmDesign);
LampSkillLabel.Parent := frmDesign;
LampSkillLabel.Left := 16;
LampSkillLabel.Top := 120;
LampSkillLabel.Width := 62;
LampSkillLabel.Height := 16;
LampSkillLabel.Font.Color := clWindowText;
LampSkillLabel.Font.Height := -15;
LampSkillLabel.Font.Name := 'MS Sans Serif';
LampSkillLabel.Font.Style := [];
LampSkillLabel.ParentFont := False;
LampSkillLabel.Caption := '0. Lamp Skill';

TripsLabel := TLabel.Create(frmDesign);
TripsLabel.Parent := frmDesign;
TripsLabel.Left := 16;
TripsLabel.Top := 144;
TripsLabel.Width := 62;
TripsLabel.Height := 16;
TripsLabel.Font.Color := clWindowText;
TripsLabel.Font.Height := -15;
TripsLabel.Font.Name := 'MS Sans Serif';
TripsLabel.Font.Style := [];
TripsLabel.ParentFont := False;
TripsLabel.Caption := '0. Loads';

UsernameEdit := TEdit.Create(frmDesign);
UsernameEdit.Parent := frmDesign;
UsernameEdit.Left := 100;
UsernameEdit.Top := 71;
UsernameEdit.Width := 121;
UsernameEdit.Height := 21;
UsernameEdit.Hint := 'Type in your Username here';
UsernameEdit.ParentShowHint := False;
UsernameEdit.ShowHint := True;
UsernameEdit.TabOrder := 8;
UsernameEdit.Text := Players[0].Name;

PasswordEdit := TEdit.Create(frmDesign);
PasswordEdit.Parent := frmDesign;
PasswordEdit.Left := 100;
PasswordEdit.Top := 94;
PasswordEdit.Width := 121;
PasswordEdit.Height := 21;
PasswordEdit.Hint := 'Type in your Password here';
PasswordEdit.ParentShowHint := False;
PasswordEdit.PasswordChar := '*';
PasswordEdit.ShowHint := True;
PasswordEdit.TabOrder := 9;
PasswordEdit.Text := Players[0].Pass;

LampSkillComboBox := TComboBox.Create(frmDesign);
LampSkillComboBox.Parent := frmDesign;
LampSkillComboBox.Left := 100;
LampSkillComboBox.Top := 117;
LampSkillComboBox.Width := 121;
LampSkillComboBox.Height := 21;
LampSkillComboBox.Hint := 'Type in the Skill you want to use a Lamp on if Found';
LampSkillComboBox.ItemHeight := 13;
LampSkillComboBox.ParentShowHint := False;
LampSkillComboBox.ShowHint := True;
LampSkillComboBox.TabOrder := 10;
LampSkillComboBox.Text := Players[0].Skill;
LampSkillComboBox.Items.Add('Strength');
LampSkillComboBox.Items.Add('Attack');
LampSkillComboBox.Items.Add('Ranged');
LampSkillComboBox.Items.Add('Magic');
LampSkillComboBox.Items.Add('Defence');
LampSkillComboBox.Items.Add('Hitpoints');
LampSkillComboBox.Items.Add('Prayer');
LampSkillComboBox.Items.Add('Agility');
LampSkillComboBox.Items.Add('Herblore');
LampSkillComboBox.Items.Add('Thieving');
LampSkillComboBox.Items.Add('Crafting');
LampSkillComboBox.Items.Add('Runecrafting');
LampSkillComboBox.Items.Add('Slayer');
LampSkillComboBox.Items.Add('Farming');
LampSkillComboBox.Items.Add('Mining');
LampSkillComboBox.Items.Add('Smithing');
LampSkillComboBox.Items.Add('Fishing');
LampSkillComboBox.Items.Add('Cooking');
LampSkillComboBox.Items.Add('Firemaking');
LampSkillComboBox.Items.Add('Woodcutting');
LampSkillComboBox.Items.Add('Fletching');
LampSkillComboBox.Items.Add('Construction');
LampSkillComboBox.Items.Add('Hunting');

LoadsEdit := TEdit.Create(frmDesign);
LoadsEdit.Parent := frmDesign;
LoadsEdit.Left := 100;
LoadsEdit.Top := 140;
LoadsEdit.Width := 121;
LoadsEdit.Height := 21;
LoadsEdit.Hint := 'Loads/player.';
LoadsEdit.ParentShowHint := False;
LoadsEdit.ShowHint := True;
LoadsEdit.TabOrder := 10;
LoadsEdit.Text := IntToStr(Players[0].{Integer2}Integers[1]);

IsActive := TCheckBox.Create(frmDesign);
IsActive.Parent := frmDesign;
IsActive.Left := 225;
IsActive.Top := 71;
IsActive.Width := 53;
IsActive.Height := 20;
IsActive.Caption := 'Active?';
IsActive.ParentShowHint := False;
IsActive.ShowHint := True;
IsActive.Hint := 'Should this Player be Active?';
IsActive.Checked := Players[0].Active;

ColorCheckBox := TCheckBox.Create(frmDesign);
ColorCheckBox.Parent := frmDesign;
ColorCheckBox.Left := 225;
ColorCheckBox.Top := 94;
ColorCheckBox.Width := 53;
ColorCheckBox.Height := 20;
ColorCheckBox.Caption := 'Colors?';
ColorCheckBox.ParentShowHint := False;
ColorCheckBox.ShowHint := True;
ColorCheckBox.Hint := 'Do you want to pick Your Own Colors?';
ColorCheckBox.Checked := Players[0].{Boolean1}Booleans[0];
ColorCheckBox.OnClick := @ChangeLabels;

String1ComboBox := TComboBox.Create(frmDesign);
String1ComboBox.Parent := frmDesign;
String1ComboBox.Left := 10;
String1ComboBox.Top := 165;
String1ComboBox.Width := 80;
String1ComboBox.Height := 21;
String1ComboBox.Hint := 'Select the Skill to Power Auto';
String1ComboBox.ItemHeight := 13;
String1ComboBox.ParentShowHint := False;
String1ComboBox.ShowHint := True;
String1ComboBox.TabOrder := 11;
String1ComboBox.Text := Players[0].{String1}Strings[0];
String1ComboBox.Items.Add('Woodcutting');
String1ComboBox.Items.Add('Mining');
String1ComboBox.Items.Add('Fishing');
String1ComboBox.Items.Add('Bone Burying');
String1ComboBox.Items.Add('Fletching');
String1ComboBox.OnChange := @String1Change;

String2ComboBox := TComboBox.Create(frmDesign);
String2ComboBox.Parent := frmDesign;
String2ComboBox.Left := 95;
String2ComboBox.Top := 165;
String2ComboBox.Width := 120;
String2ComboBox.Height := 21;
String2ComboBox.Hint := 'Select the Specific thing to Power Auto';
String2ComboBox.ItemHeight := 13;
String2ComboBox.ParentShowHint := False;
String2ComboBox.ShowHint := True;
String2ComboBox.TabOrder := 12;
String2ComboBox.Text := Players[0].{String2}Strings[1];
String2ComboBox.OnDropDown := @String1Change;

String3ComboBox := TComboBox.Create(frmDesign);
String3ComboBox.Parent := frmDesign;
String3ComboBox.Left := 220;
String3ComboBox.Top := 165;
String3ComboBox.Width := 70;
String3ComboBox.Height := 21;
String3ComboBox.Hint := 'Select the Direction to Run in if we are Attacked';
String3ComboBox.ItemHeight := 13;
String3ComboBox.ParentShowHint := False;
String3ComboBox.ShowHint := True;
String3ComboBox.TabOrder := 12;
String3ComboBox.Items.Add('N');
String3ComboBox.Items.Add('E');
String3ComboBox.Items.Add('S');
String3ComboBox.Items.Add('W');
String3ComboBox.Text := Players[0].{String3}Strings[2];

GemsCheckBox := TCheckBox.Create(frmDesign);
GemsCheckBox.Parent := frmDesign;
GemsCheckBox.Left := 225;
GemsCheckBox.Top := 117;
GemsCheckBox.Width := 78;
GemsCheckBox.Height := 20;
GemsCheckBox.Caption := 'Save Gems?';
GemsCheckBox.ParentShowHint := False;
GemsCheckBox.ShowHint := True;
GemsCheckBox.Hint := 'Do you want to save the Gems you Mine?';
GemsCheckBox.Checked := Players[0].{Boolean3}Booleans[2];
If (String1ComboBox.Text = 'Mining') then
GemsCheckBox.Visible := True
else
GemsCheckBox.Visible := False;

FletchComboBox := TComboBox.Create(frmDesign);
FletchComboBox.Parent := frmDesign;
FletchComboBox.Left := 182;
FletchComboBox.Top := 193;
FletchComboBox.Width := 100;
FletchComboBox.Height := 21;
FletchComboBox.Hint := 'Select What Type of Log the Item is';
FletchComboBox.ItemHeight := 13;
FletchComboBox.ParentShowHint := False;
FletchComboBox.ShowHint := True;
FletchComboBox.TabOrder := 12;
FletchComboBox.Items.Add('Normal');
FletchComboBox.Items.Add('Oak');
FletchComboBox.Items.Add('Willow');
FletchComboBox.Items.Add('Maple');
FletchComboBox.Items.Add('Yew');
FletchComboBox.Items.Add('Magic');
FletchComboBox.Text := FletchString[0];
If (String1ComboBox.Text = 'Fletching') then
FletchComboBox.Visible := True
else
FletchComboBox.Visible := False;

ColorsLabel := TLabel.Create(frmDesign);
ColorsLabel.Parent := frmDesign;
ColorsLabel.Left := 10;
ColorsLabel.Top := 194;
ColorsLabel.Width := 80;
ColorsLabel.Height := 12;
ColorsLabel.Font.Color := clWindowText;
ColorsLabel.Font.Height := -12;
ColorsLabel.Font.Name := 'MS Sans Serif';
ColorsLabel.Font.Style := [];
ColorsLabel.ParentFont := False;
ColorsLabel.Caption := 'Picked Color:';
If (ColorCheckBox.Checked) then
ColorsLabel.Visible := True
else
ColorsLabel.Visible := False;

ColorsEdit := TEdit.Create(frmDesign);
ColorsEdit.Parent := frmDesign;
ColorsEdit.Left := 77;
ColorsEdit.Top := 191;
ColorsEdit.Width := 80;
ColorsEdit.Height := 21;
ColorsEdit.Hint := 'Put in the Color of the Item you are Autoing. Leave as 0 for AutoPick';
ColorsEdit.ParentShowHint := False;
ColorsEdit.ShowHint := True;
ColorsEdit.TabOrder := 8;
ColorsEdit.Text := IntToStr(Players[0].{Integer1}Integers[0]);
If (ColorCheckBox.Checked) then
ColorsEdit.Visible := True
else
ColorsEdit.Visible := False;

MiningSecsLabel := TLabel.Create(frmDesign);
MiningSecsLabel.Parent := frmDesign;
MiningSecsLabel.Left := 162;
MiningSecsLabel.Top := 194;
MiningSecsLabel.Width := 80;
MiningSecsLabel.Height := 12;
MiningSecsLabel.Font.Color := clWindowText;
MiningSecsLabel.Font.Height := -12;
MiningSecsLabel.Font.Name := 'MS Sans Serif';
MiningSecsLabel.Font.Style := [];
MiningSecsLabel.ParentFont := False;
MiningSecsLabel.Caption := 'Seconds:';
If (String1ComboBox.Text = 'Mining') then
MiningSecsLabel.Visible := True
else
MiningSecsLabel.Visible := False;

MiningSecsEdit := TEdit.Create(frmDesign);
MiningSecsEdit.Parent := frmDesign;
MiningSecsEdit.Left := 210;
MiningSecsEdit.Top := 191;
MiningSecsEdit.Width := 80;
MiningSecsEdit.Height := 21;
MiningSecsEdit.Hint := 'Number of Seconds you are willing to Wait for a rock to Mine before Clicking Again';
MiningSecsEdit.ParentShowHint := False;
MiningSecsEdit.ShowHint := True;
MiningSecsEdit.TabOrder := 8;
MiningSecsEdit.Text := IntToStr(Players[0].{Integer3}Integers[2]);
If (String1ComboBox.Text = 'Mining') then
MiningSecsEdit.Visible := True
else
MiningSecsEdit.Visible := False;

BankCheckBox := TCheckBox.Create(frmDesign);
BankCheckBox.Parent := frmDesign;
BankCheckBox.Left := 164;
BankCheckBox.Top := 192;
BankCheckBox.Width := 125;
BankCheckBox.Height := 20;
BankCheckBox.Caption := 'Withdraw From Bank?';
BankCheckBox.ParentShowHint := False;
BankCheckBox.ShowHint := True;
BankCheckBox.Hint := 'Click to Withdraw Bones from Bank and Bury. Otherwise it will pick up from Floor';
BankCheckBox.Checked := Players[0].{Boolean2}Booleans[1];
If (String1ComboBox.Text = 'Bone Burying') then
BankCheckBox.Visible := True
else
BankCheckBox.Visible := False;

StartButton := TButton.Create(frmDesign);
StartButton.Parent := frmDesign;
StartButton.Left := 60;
StartButton.Top := 220;
StartButton.Width := 75;
StartButton.Height := 25;
StartButton.Hint := 'Click to Start the Script';
StartButton.Caption := 'Start Script';
StartButton.ParentShowHint := False;
StartButton.ShowHint := True;
StartButton.TabOrder := 15;
StartButton.OnClick := @StartClicked;

DonateButton := TButton.Create(frmDesign);
DonateButton.Parent := frmDesign;
DonateButton.Left := 150;
DonateButton.Top := 220;
DonateButton.Width := 75;
DonateButton.Height := 25;
DonateButton.Hint := 'Donations are always Appreciated!';
DonateButton.Caption := 'Donate!';
DonateButton.ParentShowHint := False;
DonateButton.ShowHint := True;
DonateButton.TabOrder := 15;
DonateButton.OnClick := @DonateClicked;
end;

In my Main loop:

  try
SafeInitForm;
SafeShowFormModal;
except
Writeln('Error in InitForm!');
finally
FreeForm(frmDesign);
end;

Narcle

2011-11-05 00:16:27

Try calling them without 'Safe' I had to do this to see where the real error was in the InitForm.

Wyn

2011-11-05 00:31:05

From: Narcle
Try calling them without 'Safe' I had to do this to see where the real error was in the InitForm.


I'm not sure what you mean. Threadcall in unknown.

Removing Safe from the procedure name wouldn't fix it..

I forgot to add what I did in my loop for the Gui…

  try
SafeInitForm;
SafeShowFormModal;
except
Writeln('Error in InitForm!');
finally
FreeForm(frmDesign);
end;

Narcle

2011-11-05 00:36:41

Instead of calling
SafeInitForm;
Just call
InitForm;

kanah

2011-11-05 00:56:38

Removing all of the button setup and action set up; this initform works implying that the error is a button/action setup.

Procedure InitForm;
Begin
//This is where you build your form
frmDesign := CreateForm; // This will create your form. MUST be called first.
frmDesign.Left := 100; // How many pixels from the left must the form be vissible?
frmDesign.Top := 100; // How many pixels from the top must the form be vissible?
frmDesign.Width := 500; // The width of you form in pixels
frmDesign.Height := 500; // The height of you form in pixels
frmDesign.Caption := 'Test!'; // The name of your form? This will be shown in the upper left balk
frmDesign.Color := ClWhite; // The background color of your form ("ClWhite", "ClBlack" ect, or just an color like: 123456)



(*LoadUs2;

frmDesign := CreateForm;
frmDesign.Position := poDesktopCenter;
frmDesign.Width := 313;
frmDesign.Height := 285;
frmDesign.Caption := 'TITLE';
frmDesign.Color := clInactiveCaption;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
frmDesign.OnCloseQuery := @FormClose2;

TitleLabel := TLabel.Create(frmDesign);
TitleLabel.Parent := frmDesign;
TitleLabel.Left := 28;
TitleLabel.Top := 10;
TitleLabel.Width := 277;
TitleLabel.Height := 20;
TitleLabel.Caption := 'Title';
TitleLabel.Font.Color := clWindowText;
TitleLabel.Font.Height := -17;
TitleLabel.Font.Name := 'MS Sans Serif';
TitleLabel.Font.Style := [fsBold, fsUnderline];
TitleLabel.ParentFont := False;

CreatePlayerButton := TButton.Create(frmDesign);
CreatePlayerButton.Parent := frmDesign;
CreatePlayerButton.Left := 60;
CreatePlayerButton.Top := 35;
CreatePlayerButton.Width := 83;
CreatePlayerButton.Height := 29;
CreatePlayerButton.Hint := 'Click to Create a New Player';
CreatePlayerButton.Caption := 'Create Player';
CreatePlayerButton.ParentShowHint := False;
CreatePlayerButton.ShowHint := True;
CreatePlayerButton.TabOrder := 13;
CreatePlayerButton.OnClick := @CreateNewUser;

DeletePlayerButton := TButton.Create(frmDesign);
DeletePlayerButton.Parent := frmDesign;
DeletePlayerButton.Left := 150;
DeletePlayerButton.Top := 35;
DeletePlayerButton.Width := 83;
DeletePlayerButton.Height := 29;
DeletePlayerButton.Hint := 'Click to Delete the Current Player';
DeletePlayerButton.Caption := 'Delete Player';
DeletePlayerButton.ParentShowHint := False;
DeletePlayerButton.ShowHint := True;
DeletePlayerButton.TabOrder := 13;
DeletePlayerButton.OnClick := @DeleteAPlayer;

LeftButton := TButton.Create(frmDesign);
LeftButton.Parent := frmDesign;
LeftButton.Left := 15;
LeftButton.Top := 35;
LeftButton.Width := 38;
LeftButton.Height := 29;
LeftButton.Hint := 'Click to go to the Previous Player';
LeftButton.Caption := '<---';
LeftButton.ParentShowHint := False;
LeftButton.ShowHint := True;
LeftButton.TabOrder := 13;
LeftButton.OnClick := @PressBackButton;

RightButton := TButton.Create(frmDesign);
RightButton.Parent := frmDesign;
RightButton.Left := 239;
RightButton.Top := 35;
RightButton.Width := 38;
RightButton.Height := 29;
RightButton.Hint := 'Click to go to the Next Player';
RightButton.Caption := '--->';
RightButton.ParentShowHint := False;
RightButton.ShowHint := True;
RightButton.TabOrder := 14;
RightButton.OnClick := @PressNextButton;

UsernameLabel := TLabel.Create(frmDesign);
UsernameLabel.Parent := frmDesign;
UsernameLabel.Left := 16;
UsernameLabel.Top := 73;
UsernameLabel.Width := 63;
UsernameLabel.Height := 16;
UsernameLabel.Font.Color := clWindowText;
UsernameLabel.Font.Height := -15;
UsernameLabel.Font.Name := 'MS Sans Serif';
UsernameLabel.Font.Style := [];
UsernameLabel.ParentFont := False;
UsernameLabel.Caption := '0. Username';

PasswordLabel := TLabel.Create(frmDesign);
PasswordLabel.Parent := frmDesign;
PasswordLabel.Left := 16;
PasswordLabel.Top := 96;
PasswordLabel.Width := 60;
PasswordLabel.Height := 16;
PasswordLabel.Font.Color := clWindowText;
PasswordLabel.Font.Height := -15;
PasswordLabel.Font.Name := 'MS Sans Serif';
PasswordLabel.Font.Style := [];
PasswordLabel.ParentFont := False;
PasswordLabel.Caption := '0. Password';

LampSkillLabel := TLabel.Create(frmDesign);
LampSkillLabel.Parent := frmDesign;
LampSkillLabel.Left := 16;
LampSkillLabel.Top := 120;
LampSkillLabel.Width := 62;
LampSkillLabel.Height := 16;
LampSkillLabel.Font.Color := clWindowText;
LampSkillLabel.Font.Height := -15;
LampSkillLabel.Font.Name := 'MS Sans Serif';
LampSkillLabel.Font.Style := [];
LampSkillLabel.ParentFont := False;
LampSkillLabel.Caption := '0. Lamp Skill';

TripsLabel := TLabel.Create(frmDesign);
TripsLabel.Parent := frmDesign;
TripsLabel.Left := 16;
TripsLabel.Top := 144;
TripsLabel.Width := 62;
TripsLabel.Height := 16;
TripsLabel.Font.Color := clWindowText;
TripsLabel.Font.Height := -15;
TripsLabel.Font.Name := 'MS Sans Serif';
TripsLabel.Font.Style := [];
TripsLabel.ParentFont := False;
TripsLabel.Caption := '0. Loads';

UsernameEdit := TEdit.Create(frmDesign);
UsernameEdit.Parent := frmDesign;
UsernameEdit.Left := 100;
UsernameEdit.Top := 71;
UsernameEdit.Width := 121;
UsernameEdit.Height := 21;
UsernameEdit.Hint := 'Type in your Username here';
UsernameEdit.ParentShowHint := False;
UsernameEdit.ShowHint := True;
UsernameEdit.TabOrder := 8;
UsernameEdit.Text := Players[0].Name;

PasswordEdit := TEdit.Create(frmDesign);
PasswordEdit.Parent := frmDesign;
PasswordEdit.Left := 100;
PasswordEdit.Top := 94;
PasswordEdit.Width := 121;
PasswordEdit.Height := 21;
PasswordEdit.Hint := 'Type in your Password here';
PasswordEdit.ParentShowHint := False;
PasswordEdit.PasswordChar := '*';
PasswordEdit.ShowHint := True;
PasswordEdit.TabOrder := 9;
PasswordEdit.Text := Players[0].Pass;

LampSkillComboBox := TComboBox.Create(frmDesign);
LampSkillComboBox.Parent := frmDesign;
LampSkillComboBox.Left := 100;
LampSkillComboBox.Top := 117;
LampSkillComboBox.Width := 121;
LampSkillComboBox.Height := 21;
LampSkillComboBox.Hint := 'Type in the Skill you want to use a Lamp on if Found';
LampSkillComboBox.ItemHeight := 13;
LampSkillComboBox.ParentShowHint := False;
LampSkillComboBox.ShowHint := True;
LampSkillComboBox.TabOrder := 10;
LampSkillComboBox.Text := Players[0].Skill;
LampSkillComboBox.Items.Add('Strength');
LampSkillComboBox.Items.Add('Attack');
LampSkillComboBox.Items.Add('Ranged');
LampSkillComboBox.Items.Add('Magic');
LampSkillComboBox.Items.Add('Defence');
LampSkillComboBox.Items.Add('Hitpoints');
LampSkillComboBox.Items.Add('Prayer');
LampSkillComboBox.Items.Add('Agility');
LampSkillComboBox.Items.Add('Herblore');
LampSkillComboBox.Items.Add('Thieving');
LampSkillComboBox.Items.Add('Crafting');
LampSkillComboBox.Items.Add('Runecrafting');
LampSkillComboBox.Items.Add('Slayer');
LampSkillComboBox.Items.Add('Farming');
LampSkillComboBox.Items.Add('Mining');
LampSkillComboBox.Items.Add('Smithing');
LampSkillComboBox.Items.Add('Fishing');
LampSkillComboBox.Items.Add('Cooking');
LampSkillComboBox.Items.Add('Firemaking');
LampSkillComboBox.Items.Add('Woodcutting');
LampSkillComboBox.Items.Add('Fletching');
LampSkillComboBox.Items.Add('Construction');
LampSkillComboBox.Items.Add('Hunting');

LoadsEdit := TEdit.Create(frmDesign);
LoadsEdit.Parent := frmDesign;
LoadsEdit.Left := 100;
LoadsEdit.Top := 140;
LoadsEdit.Width := 121;
LoadsEdit.Height := 21;
LoadsEdit.Hint := 'Type in how many Loads before Switching Char.';
LoadsEdit.ParentShowHint := False;
LoadsEdit.ShowHint := True;
LoadsEdit.TabOrder := 10;
LoadsEdit.Text := IntToStr(Players[0].{Integer2}Integers[1]);

IsActive := TCheckBox.Create(frmDesign);
IsActive.Parent := frmDesign;
IsActive.Left := 225;
IsActive.Top := 71;
IsActive.Width := 53;
IsActive.Height := 20;
IsActive.Caption := 'Active?';
IsActive.ParentShowHint := False;
IsActive.ShowHint := True;
IsActive.Hint := 'Should this Player be Active?';
IsActive.Checked := Players[0].Active;

ColorCheckBox := TCheckBox.Create(frmDesign);
ColorCheckBox.Parent := frmDesign;
ColorCheckBox.Left := 225;
ColorCheckBox.Top := 94;
ColorCheckBox.Width := 53;
ColorCheckBox.Height := 20;
ColorCheckBox.Caption := 'Colors?';
ColorCheckBox.ParentShowHint := False;
ColorCheckBox.ShowHint := True;
ColorCheckBox.Hint := 'Do you want to pick Your Own Colors?';
ColorCheckBox.Checked := Players[0].{Boolean1}Booleans[0];
ColorCheckBox.OnClick := @ChangeLabels;

String1ComboBox := TComboBox.Create(frmDesign);
String1ComboBox.Parent := frmDesign;
String1ComboBox.Left := 10;
String1ComboBox.Top := 165;
String1ComboBox.Width := 80;
String1ComboBox.Height := 21;
String1ComboBox.Hint := 'Select the Skill ';
String1ComboBox.ItemHeight := 13;
String1ComboBox.ParentShowHint := False;
String1ComboBox.ShowHint := True;
String1ComboBox.TabOrder := 11;
String1ComboBox.Text := Players[0].{String1}Strings[0];
String1ComboBox.Items.Add('Woodcutting');
String1ComboBox.Items.Add('Mining');
String1ComboBox.Items.Add('Fishing');
String1ComboBox.Items.Add('Bone Burying');
String1ComboBox.Items.Add('Fletching');
String1ComboBox.OnChange := @String1Change;

String2ComboBox := TComboBox.Create(frmDesign);
String2ComboBox.Parent := frmDesign;
String2ComboBox.Left := 95;
String2ComboBox.Top := 165;
String2ComboBox.Width := 120;
String2ComboBox.Height := 21;
String2ComboBox.Hint := 'Select';
String2ComboBox.ItemHeight := 13;
String2ComboBox.ParentShowHint := False;
String2ComboBox.ShowHint := True;
String2ComboBox.TabOrder := 12;
String2ComboBox.Text := Players[0].{String2}Strings[1];
String2ComboBox.OnDropDown := @String1Change;

String3ComboBox := TComboBox.Create(frmDesign);
String3ComboBox.Parent := frmDesign;
String3ComboBox.Left := 220;
String3ComboBox.Top := 165;
String3ComboBox.Width := 70;
String3ComboBox.Height := 21;
String3ComboBox.Hint := 'Select the Direction to Run in if we are Attacked';
String3ComboBox.ItemHeight := 13;
String3ComboBox.ParentShowHint := False;
String3ComboBox.ShowHint := True;
String3ComboBox.TabOrder := 12;
String3ComboBox.Items.Add('N');
String3ComboBox.Items.Add('E');
String3ComboBox.Items.Add('S');
String3ComboBox.Items.Add('W');
String3ComboBox.Text := Players[0].{String3}Strings[2];

GemsCheckBox := TCheckBox.Create(frmDesign);
GemsCheckBox.Parent := frmDesign;
GemsCheckBox.Left := 225;
GemsCheckBox.Top := 117;
GemsCheckBox.Width := 78;
GemsCheckBox.Height := 20;
GemsCheckBox.Caption := 'Save Gems?';
GemsCheckBox.ParentShowHint := False;
GemsCheckBox.ShowHint := True;
GemsCheckBox.Hint := 'Do you want to save the Gems you Mine?';
GemsCheckBox.Checked := Players[0].{Boolean3}Booleans[2];
If (String1ComboBox.Text = 'Mining') then
GemsCheckBox.Visible := True
else
GemsCheckBox.Visible := False;

FletchComboBox := TComboBox.Create(frmDesign);
FletchComboBox.Parent := frmDesign;
FletchComboBox.Left := 182;
FletchComboBox.Top := 193;
FletchComboBox.Width := 100;
FletchComboBox.Height := 21;
FletchComboBox.Hint := 'Select What Type of Log the Item is';
FletchComboBox.ItemHeight := 13;
FletchComboBox.ParentShowHint := False;
FletchComboBox.ShowHint := True;
FletchComboBox.TabOrder := 12;
FletchComboBox.Items.Add('Normal');
FletchComboBox.Items.Add('Oak');
FletchComboBox.Items.Add('Willow');
FletchComboBox.Items.Add('Maple');
FletchComboBox.Items.Add('Yew');
FletchComboBox.Items.Add('Magic');
FletchComboBox.Text := FletchString[0];
If (String1ComboBox.Text = 'Fletching') then
FletchComboBox.Visible := True
else
FletchComboBox.Visible := False;

ColorsLabel := TLabel.Create(frmDesign);
ColorsLabel.Parent := frmDesign;
ColorsLabel.Left := 10;
ColorsLabel.Top := 194;
ColorsLabel.Width := 80;
ColorsLabel.Height := 12;
ColorsLabel.Font.Color := clWindowText;
ColorsLabel.Font.Height := -12;
ColorsLabel.Font.Name := 'MS Sans Serif';
ColorsLabel.Font.Style := [];
ColorsLabel.ParentFont := False;
ColorsLabel.Caption := 'Picked Color:';
If (ColorCheckBox.Checked) then
ColorsLabel.Visible := True
else
ColorsLabel.Visible := False;

ColorsEdit := TEdit.Create(frmDesign);
ColorsEdit.Parent := frmDesign;
ColorsEdit.Left := 77;
ColorsEdit.Top := 191;
ColorsEdit.Width := 80;
ColorsEdit.Height := 21;
ColorsEdit.Hint := 'Put in the Color of the Item you are Autoing. Leave as 0 for AutoPick';
ColorsEdit.ParentShowHint := False;
ColorsEdit.ShowHint := True;
ColorsEdit.TabOrder := 8;
ColorsEdit.Text := IntToStr(Players[0].{Integer1}Integers[0]);
If (ColorCheckBox.Checked) then
ColorsEdit.Visible := True
else
ColorsEdit.Visible := False;

MiningSecsLabel := TLabel.Create(frmDesign);
MiningSecsLabel.Parent := frmDesign;
MiningSecsLabel.Left := 162;
MiningSecsLabel.Top := 194;
MiningSecsLabel.Width := 80;
MiningSecsLabel.Height := 12;
MiningSecsLabel.Font.Color := clWindowText;
MiningSecsLabel.Font.Height := -12;
MiningSecsLabel.Font.Name := 'MS Sans Serif';
MiningSecsLabel.Font.Style := [];
MiningSecsLabel.ParentFont := False;
MiningSecsLabel.Caption := 'Seconds:';
If (String1ComboBox.Text = 'Mining') then
MiningSecsLabel.Visible := True
else
MiningSecsLabel.Visible := False;

MiningSecsEdit := TEdit.Create(frmDesign);
MiningSecsEdit.Parent := frmDesign;
MiningSecsEdit.Left := 210;
MiningSecsEdit.Top := 191;
MiningSecsEdit.Width := 80;
MiningSecsEdit.Height := 21;
MiningSecsEdit.Hint := 'Number of Seconds you are willing to Wait for a rock to Mine before Clicking Again';
MiningSecsEdit.ParentShowHint := False;
MiningSecsEdit.ShowHint := True;
MiningSecsEdit.TabOrder := 8;
MiningSecsEdit.Text := IntToStr(Players[0].{Integer3}Integers[2]);
If (String1ComboBox.Text = 'Mining') then
MiningSecsEdit.Visible := True
else
MiningSecsEdit.Visible := False;

BankCheckBox := TCheckBox.Create(frmDesign);
BankCheckBox.Parent := frmDesign;
BankCheckBox.Left := 164;
BankCheckBox.Top := 192;
BankCheckBox.Width := 125;
BankCheckBox.Height := 20;
BankCheckBox.Caption := 'Withdraw From Bank?';
BankCheckBox.ParentShowHint := False;
BankCheckBox.ShowHint := True;
BankCheckBox.Hint := 'Click to Withdraw Bones from Bank and Bury. Otherwise it will pick up from Floor';
BankCheckBox.Checked := Players[0].{Boolean2}Booleans[1];
If (String1ComboBox.Text = 'Bone Burying') then
BankCheckBox.Visible := True
else
BankCheckBox.Visible := False;

StartButton := TButton.Create(frmDesign);
StartButton.Parent := frmDesign;
StartButton.Left := 60;
StartButton.Top := 220;
StartButton.Width := 75;
StartButton.Height := 25;
StartButton.Hint := 'Click to Start the Script';
StartButton.Caption := 'Start Script';
StartButton.ParentShowHint := False;
StartButton.ShowHint := True;
StartButton.TabOrder := 15;
StartButton.OnClick := @StartClicked;

DonateButton := TButton.Create(frmDesign);
DonateButton.Parent := frmDesign;
DonateButton.Left := 150;
DonateButton.Top := 220;
DonateButton.Width := 75;
DonateButton.Height := 25;
DonateButton.Hint := 'Donations are always Appreciated!';
DonateButton.Caption := 'Donate!';
DonateButton.ParentShowHint := False;
DonateButton.ShowHint := True;
DonateButton.TabOrder := 15;
DonateButton.OnClick := @DonateClicked; *)
end;

Wyn

2011-11-05 00:56:53

From: Narcle
Instead of calling
SafeInitForm;
Just call
InitForm;


Managed to crash Simba. That didn't tell me much. lolol

Oh well small re-write

Kyle Undefined

2011-11-05 01:02:48

Here's a template that I use for creating forms now, thanks to Coh3ns help. Hope this points you in the right direction.



program formTemplate;

var
form: TForm;
txtBox: TEdit;
button: TButton;
check: TCheckBox;
lbl: TLabel;

procedure onButtonClick(Sender: TObject);
begin
writeln('Clicked a button!');
end;

procedure onCheckClicked(Sender: TObject);
begin
if check.CHECKED then
WriteLn('Checkbox is checked!')
else
WriteLn('Checkbox is unchecked!');
end;

procedure formInit;
begin
form := TForm.create(nil);
with form do
begin
caption := 'Form Template';
setBounds(100, 100, 500, 300);
end;

txtBox := TEdit.Create(form);
with txtBox do
begin
parent := form;
setBounds(10, 10, 100, 25);
end;

button := TButton.Create(form);
with button do
begin
parent := form; // need this line or the button won't show up
width := 100;
height := 25;
top := 100;
left := 150;
caption := 'Example';
onClick := @onButtonClick;
end;

check := TCheckBox.Create(form);
with check do
begin
parent := form;
top := 100;
left := 75;
caption := 'Test';
onClick := @onCheckClicked;
end;

lbl := TLabel.Create(form);
with lbl do
begin
parent := form;
caption := 'Test Label';
top := 75;
left := 100;
end;

form.showModal;
end;

procedure formSafeCall(proc: string);
var
v: TVariantArray;
begin
setLength(v, 0);
threadSafeCall(proc, v);
end;

procedure formFree();
begin
form.free();
end;

begin
clearDebug();

try
formSafeCall('formInit');
except
writeln(exceptionToString(exceptionType, exceptionParam));
finally
formSafeCall('formFree');
end;
end.

KingKong

2011-11-05 01:37:41

Use the form editor in scar, make the form, save it as a dfm, use Ron's dfm parser, copy the resultant code and modify it a little bit and past in simba. Voila! A fully working form that takes like a fraction of the time to create!

Coh3n

2011-11-05 04:03:24

From: KingKong
Use the form editor in scar, make the form, save it as a dfm, use Ron's dfm parser, copy the resultant code and modify it a little bit and past in simba. Voila! A fully working form that takes like a fraction of the time to create!
Simba needs a form editor. :)

An wyn, try the template Camo posted. I was having a similar issue to yours, and when Dgby714 and I created the new template, it worked.

Dan Cardin

2011-11-05 12:52:49

Yea i was gonna say, you don't need
tab order
frmDesign.Color := clInactiveCaption;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
any of that,

setbounds will save you 4 lines per object.
People waste so much space in their forms because they set things that are already defaulted.

Wyn

2011-11-05 15:04:32

Well after some extensive work that Kanah as helped with I got my Form to load up properly.

The only problems with the form now are…

Pressing any buttons on the gui cause Simba to crash
My loading of a data file doesn't want to work.

Hmmm…I should to start ripping through srl before making my own methods more. :/

Camo I'm gonna take a look into that template…

Coh3n

2011-11-05 15:49:09

From: wyn10
Well after some extensive work that Kanah as helped with I got my Form to load up properly.

The only problems with the form now are…

Pressing any buttons on the gui cause Simba to crash
My loading of a data file doesn't want to work.

Hmmm…I should to start ripping through srl before making my own methods more. :/

Camo I'm gonna take a look into that template…
All your problems will be solved if you just use that template. ;)

Wyn

2011-11-05 15:52:23

From: Coh3n
All your problems will be solved if you just use that template. ;)


It's gonna take me a little bit to redo the gui under that.

Coh3n

2011-11-05 15:59:05

Shouldn't. All you need to do is copy your init procedure over an any clicking, etc. methods. This template may be easier as there aren't any examples.

program formTemplate;

var
form: TForm;

procedure formInit;
begin
form := TForm.create(nil);
with form do
begin
caption := 'Form Template';
setBounds(100, 100, 500, 300);
end;

form.showModal;
end;

procedure formSafeCall(proc: string);
var
v: TVariantArray;
begin
setLength(v, 0);
threadSafeCall(proc, v);
end;

procedure formFree();
begin
form.free();
end;

begin
clearDebug();

try
formSafeCall('formInit');
except
writeln(exceptionToString(exceptionType, exceptionParam));
finally
formSafeCall('formFree');
end;
end.

Wyn

2011-11-08 09:35:49

From: Coh3n
Shouldn't. All you need to do is copy your init procedure over an any clicking, etc. methods. This template may be easier as there aren't any examples.

code was here


Now trying to solve…

Exception: "" is not a valid boolean.
Error: Out Of Range at line 2502

Error is commented…

procedure formSafeCall(proc: string);
var
v: TVariantArray;
begin
setLength(v, 0);
threadSafeCall(proc, v);
end; <<-- On this line

Kyle Undefined

2011-11-08 12:44:32

Are you calling it like this?


formSafeCall('formInit');

Coh3n

2011-11-09 01:49:38

From: wyn10
Now trying to solve…

Exception: "" is not a valid boolean.
Error: Out Of Range at line 2502

Error is commented…

procedure formSafeCall(proc: string);
var
v: TVariantArray;
begin
setLength(v, 0);
threadSafeCall(proc, v);
end; <<-- On this line
That's basically useless since that doesn't actually tell you the real line. You have to call just the init procedure. Like:

// mainloop
begin
formInit();
end.

KingKong

2011-11-09 03:44:22

I don't see why you guys just dont use the form editor from scar and follow my method. Its a lot easier and faster. I never had any troubles with it.

Coh3n

2011-11-09 12:01:11

I personally don't like using the editor. I like writing the code myself. Not to mention the code generated by the editor extremely ugly.

Kyle Undefined

2011-11-09 12:12:34

^ This. I've always written the code myself, for any kind of form, in any language. Editor code that is made from a GUI is always messy.

Dan Cardin

2011-11-09 18:43:36

Not so much that its ugly as much as it probably more than triples the length of defining everything because it puts in all the unnecessary and default values anyway.