MARK behavior

njhansennjhansen Member Posts: 37
Newbie question.

When code calls record.MARK, what record gets marked? The last record retrieved, or the record whose primary key matches record.<primary key>.

The docs seem to indicate that it is the last record retrieved, both by wording and by example used, but in NoSeriesManagement.FilterSeries, there is some interesting code (inside the repeat):
  NoSeries.RESET;
  NoSeriesRelationship.SETRANGE(Code,NoSeriesCode);
  IF NoSeriesRelationship.FINDSET THEN
    REPEAT
      NoSeries.Code := NoSeriesRelationship."Series Code";
      NoSeries.MARK := TRUE;
    UNTIL NoSeriesRelationship.NEXT = 0;
  NoSeries.GET(NoSeriesCode);
  NoSeries.MARK := TRUE;
  NoSeries.MARKEDONLY := TRUE;

First, this makes it look like a field being set, but there isn't a field called Mark, so is this an alternate way of calling the Mark function?

Second, within the repeat, there is no code to read a record from No. Series, so is the assignment of the primary key implicitly causing a read, or is the mark function doing the read to set the mark?


But wait, there's more!
So, I figured I could determine what the behavior was by throwing some records into a table calling mark a couple of times with and without reading a record, and see what happened, and now I'm more confused than ever. Given a simple test table with just a code and desc column, and a simple tabular form to display it, with a single button that calls the following code:
test.reset;
test.clearmarks;
test.FINDFIRST;
test.MARK(TRUE);
test.Code := '10';
test.MARK(TRUE);
test.MARKEDONLY(TRUE);
message(format(test.count));
test.FIND('-');
REPEAT
  message(test.Desc);
UNTIL NEXT = 0;

I threw five rows into the table each with matching code and description of 1, 2, 3, 10, 20. Running the above code tells me that 2 records are marked, but the message in the repeat gives me the same value (1) five times, I assume once for each record in the table.


But wait, there's more!
If I run the code again without closing the form, it tells me that two records are selected, but the message in the repeat only gives me the value (1) once, then stops. Close and reopen the form (or add/remove a row), and it does five messages again, then subsequent runs always give one loop message.

As an aside, if I comment out the findfirst, the behavior is exactly the same (five messages then one), but the value it displays is 10.

I expected two, not one or five messages.


Help! What is going on? ](*,)

Best Answer

Answers

  • ufukufuk Member Posts: 514
    This function marks the no series record which's passed as parameter and relational no series.
    Assume you have a no series called Item1 and two relational, like Item2 and Item3. Then this function will return tree of them: Item1, Item2 and Item3.
    NoSeries.RESET;
      NoSeriesRelationship.SETRANGE(Code,NoSeriesCode); //(NoSeriesCode = Item1)
      IF NoSeriesRelationship.FINDSET THEN
        REPEAT
          NoSeries.Code := NoSeriesRelationship."Series Code";
          NoSeries.MARK := TRUE; // mark the no series in NoSeriesRelationship table (Item2, Item3)
        UNTIL NoSeriesRelationship.NEXT = 0;
      NoSeries.GET(NoSeriesCode);
      NoSeries.MARK := TRUE; //mark the no series which's passed as parameter (Item1)
      NoSeries.MARKEDONLY := TRUE;
    

    MARK functions like a temp field. You can mark it as you on it and then filter the records which are marked.
    Ufuk Asci
    Pargesoft
  • AndwianAndwian Member Posts: 627
    What is the intent of this line?
         ...
          NoSeries.Code := NoSeriesRelationship."Series Code";
         ...
    

    Thank you.

    Regards,
    Andwian
  • vaprogvaprog Member Posts: 1,140
    Hi Andiwan

    Please read the initial statement of my answer above, followed by ufuk's explanation of what the whole block of code does.
Sign In or Register to comment.