SRL Archive - OSR Help

Type mismatch.. I don't get it


rj

2013-08-15 21:12:46

So I have an array of records called Prayer, inside of the record prayer is the following things:

type Prayers = record
Location:TPoint;
name, info:string;
level:Integer;
Exceptions:TIntegerArray;
end;

Location is the row and column, name, info, level are all pretty obvious, and exceptions is a tintegerarray of all prayers that cannot be turned on at the same time as that one. for example the exceptions for protect from melee would be the prayer id for prot mage, range, retribution, smite, and redemption as shown here:

with Prayer[19] do
begin
Location := Point(3, 4);
name := 'Protect from melee';
info := 'Decreases NPC melee damage by 40%';
Exceptions := [17, 18, 22, 24];
level := 43;
end;

In my form, I am trying to make it idiot proof and not letting people add prayers to the list if they can't have it on (such as selection chivalry and piety). How I am trying to do this:

-When the user clicks the "add prayer" button, it goes to "updateprayer" procedure, this procedure then gets the TList item index, and then does a for loop for the prayers selected, and inside of that for loop does another for loop for each prayer that is selected Exceptions list. This is were I am getting the type mismatch.. please ignore the sloppy code I am just trying to get it working before cleaning it up
procedure UpdatePrayerList(sender:TObject);
var
i, l:Integer;
begin
Writeln(Prayer[0].Exceptions[0]);
case sender of
FormData.PrayButtons[0]:
begin
if not IntInArray(FormData.Options[4].ItemIndex, PrayUse) then
begin
if not IntInArray(FormData.Options[4].ItemIndex, Prayer[FormData.Options[4].ItemIndex].exceptions) then
begin
for i := 0 to high(PrayUse) do
begin
for l := 0 to high(Prayer[PrayUse[i]].Exceptions) do
begin
if (Prayer[FormData.Options[4].ItemIndex] = Prayer[PrayUse[i]].Exceptions[l]) then
error('You can not use ' + Prayer[FormData.Options[4].ItemIndex].name + ' and ' Prayer[Exception[l]].name + ' at the same time!');
end;
end;
TIAAppend(PrayUse, FormData.Options[4].ItemIndex);
FormData.Chosen[4].ITEMS.Clear;
for i := 0 to high(prayUse) do
FormData.Chosen[4].ITEMS.Add(Prayer[PrayUse[i]].name);
end;
end else if IntInArray(FormData.Options[4].ItemIndex, PrayUse) then
begin
error('You already added that Prayer!');
end;
end;
end;
end;


The error falls at this line –>

if (Prayer[FormData.Options[4].ItemIndex] = Prayer[PrayUse[i]].Exceptions[l]) then

Help would be appreciated, I can post the whole script if needed (is pretty long so I don't want to if I don't have to)


Script:

Fixed :s

Le Jingle

2013-08-15 22:04:36

Maybe I am missing something, but as far as I know, a type of ``TListBox'' does not equal a type of ``integer''

Edit: I think you are trying to compare 2 unrelated things, perhaps I am wrong as it's been too long since last use of forms in ps. But try looking at the logic being evaluated and the ``integers'' in question being compared. I'm quite certain the compiler won't compile due to type differences for a good reason ;)

Edit 2: Okay I bit the bullet and looked through the posted script. With lack of detail, you are comparing an array type of ``Prayers'' with the ``Prayers'' type int array, Exceptions… I would like to point back to the first Edit, namely reviewing logic flow through script.

rj

2013-08-15 22:05:50

From: Le Jingle
Maybe I am missing something, but as far as I know, a type of ``TListBox'' does not equal a type of ``integer''


TLisBox.ItemIndex returns an integer

riwu

2013-08-16 07:19:22

Prayer[FormData.Options[4].ItemIndex] is a Prayers type, not an integer.

Prayer: array[0..29] of Prayers;

rj

2013-08-16 15:52:14

From: riwu
Prayer[FormData.Options[4].ItemIndex] is a Prayers type, not an integer.

Prayer: array[0..29] of Prayers;

oo i see I changed that but Am still getting a type mismatch:

if ([FormData.Options[4].ItemIndex] = Prayer[PrayUse[i]].Exceptions[l]) then

Prayer[PrayUse].Exceptions[l]) is were the type mismatch is… even though for instance Prayer[0].Exception[0] would be a integer correct?

EDIT:

I FOUND THE PROBLEM: i ADDED A "[" WHICH pretty much rasied hell cba to explain thank you all