PDA

View Full Version : Ordinal Type required and Incompatable Types!



Daniel
08-02-2008, 12:21 PM
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
08-03-2008, 04:25 AM
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
08-03-2008, 04:45 AM
In Delphi, cases don't accept strings (or, in this case, TCaptions).

R0b0t1
08-03-2008, 05:09 AM
If..then..else ... then.

Daniel
08-03-2008, 05:32 AM
Nevermind, i got it figured out and i managed to fix a bug ;)

the scar noob
08-06-2008, 03:19 PM
Nevermind, i got it figured out and i managed to fix a bug ;)


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

Daniel
08-09-2008, 10:53 AM
Well Dan, if I look to your sig, you seem to fail a lot:p

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

Dan Cardin
08-09-2008, 08:34 PM
or you could use a TColorDialog and make it shorter as well as having more colors :).

Daniel
08-10-2008, 02:26 AM
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
08-18-2008, 04:20 PM
Delphi's case statements do not accept strings, also this is a terribad way to go about this :(

Daniel
08-19-2008, 07:19 AM
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 ;)