How to Compare two tables to create an Excel report

redhotmustangredhotmustang Member Posts: 91
Hi there,

I'm programming an excel report that needs to compare values from two tables in order to create an Excel sheet with the students' classifications.
Excel sheet structure

(Subject) | A | B | C (Type of Classification)
Math | X | |
Sciences | | X |


First, I went to the type of Classification for that Subject.
The result is something like "A", "B", "C". Let's say it founds 3 records.
clear(i);
Clear(varClass);

rClassTypes.reset;
rClassTypes.SETRANGE("Classification Type","Classification Type");
IF rClassTypes.FIND('-') THEN BEGIN
   REPEAT
   i := i + 1;
   varClass[i] := rClass."Class. Code"; //Something like 'A','B','c', and so on.
   UNTIL rClassTypes.next = 0;
END;

rEval.RESET;
rEval.SETRANGE(Student,Student);
rEval.SETRANGE(Subject,Subject); //And more setranges (that don't matter for this topic)
     
IF rEval.FIND('-') THEN BEGIN
   REPEAT
   IF rEval."Subject Evaluation" = varClass[i] THEN BEGIN
      message('match');
      //xlActPage.Range(Column + FORMAT(Line)).Value := 'X';
   END;
   UNTIL rEval.next = 0;

I need that the first rEval record is compared with varClass[1], varClass[2], varClass[3] (and so on, as long as this array as values), I need that the second rEval record is compared again with that array (varClass[1], varClass[2], varClass[3]...).

I mean as long as there are records for the rEval, all of them need to be compared with ALL the varClasses values, to see if they match.

I need a cycle that increases "i" until "i" ends keeping rEval in the same record. When "i" ends, rEval moves to the next record, and starts comparing itself again with "i" which is now equal to 1, increasing itself until it ends. And so on.

Thanks in advance!
Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)

Answers

  • AlbertvhAlbertvh Member Posts: 516
    Hi
    You could do the following
    IF rEval.FIND('-') THEN BEGIN
       REPEAT
       FOR x := 1 TO ARRAYLEN(VarClass) DO
          IF rEval."Subject Evaluation" = varClass[x] THEN BEGIN
            message('match');
            //xlActPage.Range(Column + FORMAT(Line)).Value := 'X';
         END;
       UNTIL rEval.next = 0;
    

    where x is type Integer


    Albert
  • redhotmustangredhotmustang Member Posts: 91
    Thanks Albert. It was something like that I was looking for.

    Actually, I had to change your code a little bit.
    IF rEval.FIND('-') THEN BEGIN
        REPEAT
        FOR i := 1 TO x DO begin
           IF rEval."Subject Evaluation" = varClass[i] THEN BEGIN
              message('match');
              //xlActPage.Range(Column + FORMAT(Line)).Value := 'X';
           END;
         END;
    

    Where, x is an integer and is equal to rClassTypes.count.
    Using arraylen(varClass) would return the total number of dimensions for that array, and not only the number of dimensions being used, which was I wanted.

    Thank You.
    Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)
Sign In or Register to comment.