SRL Archive - OSR Help

Type mismatch


rj

2013-02-17 19:33:41

I have no idea why I'm getting this:

[Error] C:\Simba\Scripts\test.simba(15:5): Type mismatch at line 14
Compiling failed.

Line 14:

'Varrock':

Whole script:

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

procedure i;
begin
Case LowerCase(City) Of
'Varrock':
Begin
Case LowerCase(Purpose) Of
'1':
Writeln('Varrock.1');
'2':
Writeln('Varrock.2');
'3':
Writeln('3');
'4':
Writeln('4');
End;
End;
'Fally':
Begin
Case LowerCase(Purpose) Of
'1':
Writeln('Fally.1');
'2':
Writeln('Fally.2');
'3':
Writeln('Fally.3');
'4':
Writeln('Fally.4');
End;
End;
'Edgeville':
Begin
Case LowerCase(Purpose) Of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
'Wilderness':
Begin
Case LowerCase(Purpose) Of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
'Lumberidge':
Begin
Case LowerCase(Purpose) Of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
End;
End;
procedure SaveFormInfo(Sender: TObject);
begin
City := CityEnter.TEXT;
Purpose := PurposeEnter.TEXT;
i;
//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;
// ONCLICK := @TryStuff;
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.

Press Play

2013-02-17 19:36:45

City,Purpose:TEdit;
The variable 'city' is a TEdit record.
'Varrock'
Is a string?

Not really to sure what a TEdit record is though, because I've never messed with forms. I'll have a look..

Le Jingle

2013-02-17 19:36:57

A TEdit type cannot have string type case statements.

rj

2013-02-17 19:42:05

Ok so i switched it to:

CityEnter,PurposeEnter:TEdit;
City,Purpose:String;

and i got the"something went wrong with simba" error.

And if A TEdit type cannot have string type case statements then how am i supposed to do this? lol, unless i am supposed to do like 60 if then statements

Press Play

2013-02-17 19:46:45

I'm probably not the best person to ask since I know little to nothing about forms, but what exactly are you trying to make a form for? And what tutorial are you following? I suggest this one :) http://villavu.com/forum/showthread.php?t=41418&p=520204

Sorry, I don't think I can really help any further :(

rj

2013-02-17 19:49:33

I don't see anything in it about cases inside of cases or cases like mine :(

Le Jingle

2013-02-17 20:08:05

I find it hard to believe that you didn't see anything relating to your TEdit problem (via the suggested helper link from -daazndagger-).

Look under the section, TEdit;

There happens to be an example that shows, TEdit1.Text, hmmmmmmmm

-Lj

rj

2013-02-17 21:33:16

From: Le Jingle
I find it hard to believe that you didn't see anything relating to your TEdit problem (via the suggested helper link from -daazndagger-).

Look under the section, TEdit;

There happens to be an example that shows, TEdit1.Text, hmmmmmmmm

-Lj

Actually the part in the tutorial that shows TEdit1.text is not using the combo box like in my code, and i read the part of the tut that deals with combo box and it still doe snot fix my problem by doing this:

City:TComboBox;
Purpose:TComboBox;
and
City.Items.Add('Varrock');
City.Items.Add('Fally');
City.Items.Add('Edgeville');
City.Items.Add('Wilderness');
City.Items.Add('Draynor');
City.Items.Add('Lumberidge');

rj

2013-02-18 16:58:27

bump

King

2013-02-18 17:06:13

Why not just use Cynicrus's form designer?…

Mark

2013-02-18 17:14:18

like i said in another thread you made afew days ago you would of found everything you needed from a script i stopped making in the multiple script section

this is how you check which option is selected.

  case City.ItemIndex of
1://Fally

2://Edgeville

3://Wilderness

4://ect..
end;


rj

2013-02-18 17:58:03

From: CRU1Z1N
like i said in another thread you made afew days ago you would of found everything you needed from a script i stopped making in the multiple script section

this is how you check which option is selected.

  case City.ItemIndex of
1://Fally

2://Edgeville

3://Wilderness

4://ect..
end;



OK thanks but now I am getting this error:


[Error] C:\Simba\Scripts/test.simba(86:21): Semicolon (';') expected at line 85
Compiling failed.


Line 85:

City := CityEnter.TEXT; 

Mark

2013-02-18 18:02:59

From: rjj95
OK thanks but now I am getting this error:


[Error] C:\Simba\Scripts/test.simba(86:21): Semicolon (';') expected at line 85
Compiling failed.


Line 85:

City := CityEnter.TEXT; 


you need to post your full code so i can see what your doing wrong i cant see any alteration you have made.

edit: also make sure your city variable is to a string

rj

2013-02-18 18:04:59

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

procedure i;
begin
case City.Text of
'Varrock':
Begin
case Purpose.Text of
'1':
Writeln('Varrock.1');
'2':
Writeln('Varrock.2');
'3':
Writeln('3');
'4':
Writeln('4');
End;
End;
'Fally':
Begin
case Purpose.Text of
'1':
Writeln('Fally.1');
'2':
Writeln('Fally.2');
'3':
Writeln('Fally.3');
'4':
Writeln('Fally.4');
End;
End;
'Edgeville':
Begin
case Purpose.Text of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
'Wilderness':
Begin
case Purpose.Text of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
'Lumberidge':
Begin
case Purpose.Text of
'1':
Writeln('Edgeville.1');
'2':
Writeln('Edgeville.2');
'3':
Writeln('Edgeville.3');
'4':
Writeln('Edgeville.4');
End;
End;
End;
End;
procedure SaveFormInfo(Sender: TObject);
begin
City := CityEnter.TEXT;
Purpose := PurposeEnter.TEXT;
i;
//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;
// ONCLICK := @TryStuff;
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
TComboBox2.Items.Add('Varrock');
TComboBox2.Items.Add('Fally');
TComboBox2.Items.Add('Edgeville');
TComboBox2.Items.Add('Wilderness');
TComboBox2.Items.Add('Draynor');
TComboBox2.Items.Add('Lumberidge');
//End items

TComboBox2.Text := 'City';
//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.

Mark

2013-02-18 18:25:15

you had them wrong way

CityEnter := City.TEXT;

also the line below

PurposeEnter := Purpose.TEXT;

rj

2013-02-18 18:28:22

From: CRU1Z1N
you had them wrong way

CityEnter := City.TEXT;

also the line below

PurposeEnter := Purpose.TEXT;


Now i get the error message "something went wrong with simba press ok or cancel"

Mark

2013-02-18 18:41:44

your not using the combo box in your script so atm your script does nothing with the data you entered.

Echo_

2013-02-18 18:46:14

Instead of using the nested case statement, can't you just do:

WriteLn(City.Text + '.' + Purpose.Text);

rj

2013-02-18 18:59:26

From: CRU1Z1N
your not using the combo box in your script so atm your script does nothing with the data you entered.


What do you mean im not using the combo box, it's popping up?

Mark

2013-02-18 19:08:01

look at your code its not using any of the options selected from the combo box like i said earlier

rj

2013-02-18 19:12:00

TComboBox4.Items.Add('1');
TComboBox4.Items.Add('2');
TComboBox4.Items.Add('3');
TComboBox4.Items.Add('4');
there I added that and it still gives the error, I don't get how it's "not using them"

Mark

2013-02-18 19:18:38

to make it easy as im tired and cant explain properly atm so here it is compare this to yours see where you went wrong line by line

program new;
var
DsgnForm:TForm;
TLabel0,TLabel1,TLabel3: TLabel;
TButton5: TButton;
CityCombo,PurposeCombo: TComboBox;

City,Purpose:TEdit;

const
default = 'Times New Roman';

procedure i;
begin
case CityCombo.ITEMINDEX of
0:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Varrock.1');
1:
Writeln('Varrock.2');
2:
Writeln('3');
3:
Writeln('4');
End;
End;
1:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Fally.1');
1:
Writeln('Fally.2');
2:
Writeln('Fally.3');
3:
Writeln('Fally.4');
End;
End;
2:
Begin
case PurposeCombo.ITEMINDEX of
0:Writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
3:
Begin
case PurposeCombo.ITEMINDEX of
0:writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
4:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
End;
End;


procedure SaveFormInfo(Sender: TObject);
begin
DsgnForm.ModalResult := mrOk;
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;
// ONCLICK := @TryStuff;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox2\\
CityCombo:=TComboBox.Create(DsgnForm);
with CityCombo 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 := 'City';
//Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox4\\
PurposeCombo:=TComboBox.Create(DsgnForm);
with PurposeCombo 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;
i;
DsgnForm.Free;

end.

rj

2013-02-18 20:18:37

From: CRU1Z1N
to make it easy as im tired and cant explain properly atm so here it is compare this to yours see where you went wrong line by line

program new;
var
DsgnForm:TForm;
TLabel0,TLabel1,TLabel3: TLabel;
TButton5: TButton;
CityCombo,PurposeCombo: TComboBox;

City,Purpose:TEdit;

const
default = 'Times New Roman';

procedure i;
begin
case CityCombo.ITEMINDEX of
0:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Varrock.1');
1:
Writeln('Varrock.2');
2:
Writeln('3');
3:
Writeln('4');
End;
End;
1:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Fally.1');
1:
Writeln('Fally.2');
2:
Writeln('Fally.3');
3:
Writeln('Fally.4');
End;
End;
2:
Begin
case PurposeCombo.ITEMINDEX of
0:Writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
3:
Begin
case PurposeCombo.ITEMINDEX of
0:writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
4:
Begin
case PurposeCombo.ITEMINDEX of
0:
Writeln('Edgeville.1');
1:
Writeln('Edgeville.2');
2:
Writeln('Edgeville.3');
3:
Writeln('Edgeville.4');
End;
End;
End;
End;


procedure SaveFormInfo(Sender: TObject);
begin
DsgnForm.ModalResult := mrOk;
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;
// ONCLICK := @TryStuff;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox2\\
CityCombo:=TComboBox.Create(DsgnForm);
with CityCombo 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 := 'City';
//Text := Items[0];
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TComboBox4\\
PurposeCombo:=TComboBox.Create(DsgnForm);
with PurposeCombo 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;
i;
DsgnForm.Free;

end.


Worked fine but… I couldn't copy yours over to my original one.. couldn't figure out the problem

Mark

2013-02-18 20:53:14

you never actually used the combos boxes liek i told you you where using those useless TEdit's you created which actually had no values and you where assigning them to a string with no value

rj

2013-02-18 22:01:23

Who the hell just De-repped for 'bumping under 24 hours'

Backseat modding pl0x.

Mark

2013-02-19 07:00:26

I have answered you many times I don't understand why you needed to bump an answered question the code I provided compiles and works the way you where trying.

If you needed more help you should post your question in more detail rather than just bump as anybody reading will see you have been answered and will wonder why the hell you are bumping.