SRL Archive - OSR Help

Why the hell am I getting an error here?


rj

2013-02-17 18:04:10

procedure SaveFormInfo(Sender: TObject);
var
City,Purpose:String;
begin
City := CityEnter.Text
Purpose := PurposeEnter.TEXT;
DsgnForm.CLOSE;
end;

[Error] C:\Simba\Scripts\formforss.simba(23:21): Semicolon (';') expected at line 22
Compiling failed.

LINE 22:

City := CityEnter.Text 


Before anyone says it… making it

City := CityEnter.Text;

Gives the same error

Sjoe

2013-02-17 18:14:55

Have u tried turning it off and on again?

i luffs yeww

2013-02-17 18:15:12

CityEnter most likely isn't correct. What is CityEnter? It's expecting "City := CityEnter;" I believe.

rj

2013-02-17 18:16:28

In Chris's example this works fine:

procedure SaveFormInfo(Sender: TObject);
begin
FormUser := username.TEXT
FormHue := Hue.TEXT;
FormFood := Food.TEXT; // Saving the text, before we close the form
DsgnForm.CLOSE;
end;

I declared all of them as strings

Olly

2013-02-17 18:16:48

purposeenter.Caption ?

i luffs yeww

2013-02-17 18:18:46

From: rjj95
In Chris's example this works fine:

procedure SaveFormInfo(Sender: TObject);
begin
FormUser := username.TEXT
FormHue := Hue.TEXT;
FormFood := Food.TEXT; // Saving the text, before we close the form
DsgnForm.CLOSE;
end;

I declared all of them as strings


That's not what I asked. What is CityEnter?

rj

2013-02-17 18:19:38

Uhhh, looks like this:

 TComboBox4:=TComboBox.Create(DsgnForm);
with TComboBox4 do
begin
Parent:=DsgnForm;
Left:=75;
Top:=83;
Width:=120;
Height:=21;
//add your items here
Items.Add('1');
Items.Add('2');
Items.Add('3');
Items.Add('4');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
DsgnForm.SHOWMODAL;
DsgnForm.Free;
end;


City enter is this:

 TComboBox2:=TComboBox.Create(DsgnForm);
with TComboBox2 do
begin
Parent:=DsgnForm;
Left:=76;
Top:=45;
Width:=118;
Height:=21;
//add your items here
Items.Add('Varrock');
Items.Add('Fally');
Items.Add('Edgeville');
Items.Add('Wilderness');
Items.Add('Draynor');
Items.Add('Lumberidge');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;

i luffs yeww

2013-02-17 18:21:26

So CityEnter is a TComboBox or how are you dealing with it? Can you just post the whole script?

rj

2013-02-17 18:23:02

var
DsgnForm:TForm;
TLabel0,TLabel1,TLabel3: TLabel;
TButton5: TButton;
TComboBox2,TComboBox4: TComboBox;
CityEnter,PurposeEnter:String;
//City,Purpose:String;
const
default = 'Times New Roman';


//procedure YourClickProcedure(Sender: TObject);
//begin
// ShowMessage('click');
//end;

procedure SaveFormInfo(Sender: TObject);
var
City,Purpose:String;
begin
City := CityEnter.Text
Purpose := PurposeEnter.TEXT;
DsgnForm.CLOSE;
end;


procedure InitForm;
begin
//DsgnForm\\
DsgnForm:=TForm.Create(nil);
with DsgnForm do
begin
Caption:='form';
Left:=351;
Top:=393;
Width:=320;
Height:=240;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel0\\
TLabel0:=TLabel.Create(DsgnForm);
with TLabel0 do
begin
Parent:=DsgnForm;
Caption:='hi';
Left:=83;
Top:=15;
Width:=114;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel1\\
TLabel1:=TLabel.Create(DsgnForm);
with TLabel1 do
begin
Parent:=DsgnForm;
Caption:='Location';
Left:=20;
Top:=47;
Width:=41;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel3\\
TLabel3:=TLabel.Create(DsgnForm);
with TLabel3 do
begin
Parent:=DsgnForm;
Caption:='Purpose';
Left:=20;
Top:=85;
Width:=40;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TButton5\\
TButton5:=TButton.Create(DsgnForm);
with TButton5 do
begin
Parent:=DsgnForm;
Caption:='start!';
Left:=62;
Top:=198;
Width:=174;
Height:=29;
ONCLICK := @SaveFormInfo;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox2\\
TComboBox2:=TComboBox.Create(DsgnForm);
with TComboBox2 do
begin
Parent:=DsgnForm;
Left:=76;
Top:=45;
Width:=118;
Height:=21;
//add your items here
Items.Add('Varrock');
Items.Add('Fally');
Items.Add('Edgeville');
Items.Add('Wilderness');
Items.Add('Draynor');
Items.Add('Lumberidge');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox4\\
TComboBox4:=TComboBox.Create(DsgnForm);
with TComboBox4 do
begin
Parent:=DsgnForm;
Left:=75;
Top:=83;
Width:=120;
Height:=21;
//add your items here
Items.Add('1');
Items.Add('2');
Items.Add('3');
Items.Add('4');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
DsgnForm.SHOWMODAL;
DsgnForm.Free;
end;

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


procedure ShowFormModal;
begin
DsgnForm.ShowModal;
end;


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


begin
SafeInitForm;
SafeShowFormModal;
end.

i luffs yeww

2013-02-17 18:23:44

Like I said, CityEnter is the problem. CityEnter is a String, and Strings don't have a .Text field.

rj

2013-02-17 18:25:25

From: i luffs yeww
Like I said, CityEnter is the problem. CityEnter is a String, and Strings don't have a .Text field.


The awkward moment when I realize in Chris!'s example script he declared it as a TEdit. LOL

Fixed, now I'm getting an error "something went wrong with simba" when I click start sec ill see if i can fix

i luffs yeww

2013-02-17 18:54:42

From: rjj95
The awkward moment when I realize in Chris!'s example script he declared it as a TEdit. LOL

Fixed, now I'm getting an error "something went wrong with simba" when I click start sec ill see if i can fix


If you take out the call to SafeShowFormModal it works fine.

rj

2013-02-17 18:54:44

Ok I found the error:

Program exception! 
Stacktrace:

Exception class: EPSException
Message: Could not call proc
$00669BF5
$0066931F
$0054EE2F
$0054F356
$0054F8B1
$0054ED3A
$0040C37A
$004EBC0D
$00568BE7
$0050E94E
$005804CF
$74C18817
$74C1898E
$74C1C306
$74C1C367
$744BB4BA
$744BB51C
Simba Version: 992

Uhh.. I'm not sure what to do to fix it?

If i close out of the form it sais:
Error: Exception: Access violation at line 166

Line 166:
ThreadSafeCall('ShowFormModal', v);


I tried to remove it like above but I am not sure how without messing the whole thing up?

i luffs yeww

2013-02-17 18:59:12

From: rjj95
Ok I found the error:

Program exception! 
Stacktrace:

Exception class: EPSException
Message: Could not call proc
$00669BF5
$0066931F
$0054EE2F
$0054F356
$0054F8B1
$0054ED3A
$0040C37A
$004EBC0D
$00568BE7
$0050E94E
$005804CF
$74C18817
$74C1898E
$74C1C306
$74C1C367
$744BB4BA
$744BB51C
Simba Version: 992

Uhh.. I'm not sure what to do to fix it?


Well I already posted one fix, but just so you know why it happened, you were calling DsgnForm.ShowModal in InitForm, and then freeing it after. And then in ShowFormModal you were trying to call it again after it was freed. I think that's why it caused an error.

So you can either take out the call to ShowFormModal or you can move DsgnForm.ShowModal; DsgnForm.Free; to where it should be (in ShowFormModal). Either way will work, but the latter is more correct. Freeing the Form should actually be somewhere else even, I believe, but I don't know. I've never worked with forms.

rj

2013-02-17 19:01:09

From: i luffs yeww
Well I already posted one fix, but just so you know why it happened, you were calling DsgnForm.ShowModal in InitForm, and then freeing it after. And then in ShowFormModal you were trying to call it again after it was freed. I think that's why it caused an error.

So you can either take out the call to ShowFormModal or you can move DsgnForm.ShowModal; DsgnForm.Free; to where it should be (in ShowFormModal). Either way will work, but the latter is more correct. Freeing the Form should actually be somewhere else even, I believe, but I don't know. I've never worked with forms.


I just took out

// DsgnForm.SHOWMODAL;
//DsgnForm.Free;

Still got the same error

i luffs yeww

2013-02-17 19:02:08

From: rjj95
I just took out

// DsgnForm.SHOWMODAL;
//DsgnForm.Free;

Still got the same error


That's not what I said to do.. Here:


var
DsgnForm:TForm;
TLabel0,TLabel1,TLabel3: TLabel;
TButton5: TButton;
TComboBox2,TComboBox4: TComboBox;
CityEnter,PurposeEnter:String;
//City,Purpose:String;
const
default = 'Times New Roman';


//procedure YourClickProcedure(Sender: TObject);
//begin
// ShowMessage('click');
//end;

procedure SaveFormInfo(Sender: TObject);
var
City,Purpose:String;
begin
City := CityEnter;
Purpose := PurposeEnter;
DsgnForm.CLOSE;
end;


procedure InitForm;
begin
//DsgnForm\\
DsgnForm:=TForm.Create(nil);
with DsgnForm do
begin
Caption:='form';
Left:=351;
Top:=393;
Width:=320;
Height:=240;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel0\\
TLabel0:=TLabel.Create(DsgnForm);
with TLabel0 do
begin
Parent:=DsgnForm;
Caption:='hi';
Left:=83;
Top:=15;
Width:=114;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel1\\
TLabel1:=TLabel.Create(DsgnForm);
with TLabel1 do
begin
Parent:=DsgnForm;
Caption:='Location';
Left:=20;
Top:=47;
Width:=41;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TLabel3\\
TLabel3:=TLabel.Create(DsgnForm);
with TLabel3 do
begin
Parent:=DsgnForm;
Caption:='Purpose';
Left:=20;
Top:=85;
Width:=40;
Height:=14;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TButton5\\
TButton5:=TButton.Create(DsgnForm);
with TButton5 do
begin
Parent:=DsgnForm;
Caption:='start!';
Left:=62;
Top:=198;
Width:=174;
Height:=29;
ONCLICK := @SaveFormInfo;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox2\\
TComboBox2:=TComboBox.Create(DsgnForm);
with TComboBox2 do
begin
Parent:=DsgnForm;
Left:=76;
Top:=45;
Width:=118;
Height:=21;
//add your items here
Items.Add('Varrock');
Items.Add('Fally');
Items.Add('Edgeville');
Items.Add('Wilderness');
Items.Add('Draynor');
Items.Add('Lumberidge');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox4\\
TComboBox4:=TComboBox.Create(DsgnForm);
with TComboBox4 do
begin
Parent:=DsgnForm;
Left:=75;
Top:=83;
Width:=120;
Height:=21;
//add your items here
Items.Add('1');
Items.Add('2');
Items.Add('3');
Items.Add('4');
//End items

Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
end;

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


procedure ShowFormModal;
begin
DsgnForm.ShowModal;
end;


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


begin
SafeInitForm;
SafeShowFormModal;
DsgnForm.Free;
end.

rj

2013-02-17 19:03:59

TY.

rj

2013-02-17 19:07:03

One more thing: Can i do a case inside of a case like:

Begin
Case LowerCase(City) Of
Case LowerCase(Number) Of
'Varrock':
Begin
Begin
'1':
'2':
'3':
'4':
End;
End;
End;