Results 1 to 5 of 5

Thread: Type mismatch.. I don't get it

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Type mismatch.. I don't get it

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

    Simba Code:
    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:

    Simba Code:
    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
    Simba Code:
    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 -->

    Simba Code:
    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:

    Simba Code:
    Fixed :s

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    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.
    Last edited by Le Jingle; 08-16-2013 at 05:02 AM.

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    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

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Prayer[FormData.Options[4].ItemIndex] is a Prayers type, not an integer.
    Simba Code:
    Prayer: array[0..29] of Prayers;

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Prayer[FormData.Options[4].ItemIndex] is a Prayers type, not an integer.
    Simba Code:
    Prayer: array[0..29] of Prayers;
    oo i see I changed that but Am still getting a type mismatch:

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

    Prayer[PrayUse[i]].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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •