SRL Archive - Delphi/FPC Help and Tutorials

Ordinal Type required and Incompatable Types!


Daniel

2008-08-02 08:21:04

Here's the procedure:

procedure TForm1.ComboBox3Change(Sender: TObject);
begin
case (Form1.ComboBox3.Text) of //The ordinal error.
'Black': Form1.RichEdit1.SelAttributes.Color:=clBlack; //The Incompatable types error.
'Grey': Form1.RichEdit1.SelAttributes.Color:=clGray;
'White': Form1.RichEdit1.SelAttributes.Color:=clWhite;
'Cyan': Form1.RichEdit1.SelAttributes.Color:=clSkyBlue;
'Blue': Form1.RichEdit1.SelAttributes.Color:=clBlue;
'Navy': Form1.RichEdit1.SelAttributes.Color:=clNavy;
'Red': Form1.RichEdit1.SelAttributes.Color:=clRed;
'Maroon': Form1.RichEdit1.SelAttributes.Color:=clMaroon;
'Yellow': Form1.RichEdit1.SelAttributes.Color:=clYellow;
'Lime': Form1.RichEdit1.SelAttributes.Color:=clLime;
'Green': Form1.RichEdit1.SelAttributes.Color:=clGreen;
'Teal': Form1.RichEdit1.SelAttributes.Color:=clTeal;
'Dark Green': Form1.RichEdit1.SelAttributes.Color:=clMoneyGreen;
'Purple': Form1.RichEdit1.SelAttributes.Color:=clPurple;
end;
end;

And here are the errors i am receiving:

[Error] Unit1.pas(237): Ordinal type required
[Error] Unit1.pas(238): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(239): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(240): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(241): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(242): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(243): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(244): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(245): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(246): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(247): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(248): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(249): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(250): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(251): Incompatible types: 'Integer' and 'String'

Please help, as i have no idea how i could receive those errors. I have googled it, and failed. It works in SCAR so there must be a difference. Please help, thanks ;)

Rep++ if you do help ;)

R0b0t1

2008-08-03 00:25:36

I think the color may be a string, have you checked the Codehints?



Also: The only two reasons this would occur: Form1.ComboBox3.Text is an integer (it may be in the if its infact a pointer), or Form1.RichEdit1.SelAttributes.Color is a string.

bullzeye95

2008-08-03 00:45:30

In Delphi, cases don't accept strings (or, in this case, TCaptions).

R0b0t1

2008-08-03 01:09:02

If..then..else … then.

Daniel

2008-08-03 01:32:36

Nevermind, i got it figured out and i managed to fix a bug ;)

the scar noob

2008-08-06 11:19:58

[QUOTE=Dan's The Man;442137]Nevermind, i got it figured out and i managed to fix a bug ;)[/QUOTE]

[offtopic]
Well Dan, if I look to your sig, you seem to fail a lot:p
[/offtopic]

Daniel

2008-08-09 06:53:29

From: the scar noob
[offtopic]
Well Dan, if I look to your sig, you seem to fail a lot:p
[/offtopic]

Lol, i changed that a while ago :p I just liked those pictures :p

Dan Cardin

2008-08-09 16:34:09

or you could use a TColorDialog and make it shorter as well as having more colors :).

Daniel

2008-08-09 22:26:31

From: Dan Cardin
or you could use a TColorDialog and make it shorter as well as having more colors :).

I used a TColorGrid :D You can see my work in the Misc. Links and Programs forums, DanWord ;)

Freddy1990

2008-08-18 12:20:46

Delphi's case statements do not accept strings, also this is a terribad way to go about this :(

Daniel

2008-08-19 03:19:04

From: Freddy1990
Delphi's case statements do not accept strings, also this is a terribad way to go about this :(

I don't care anymore, i had changed my method anyway ;)