MARK behavior

njhansen
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):
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:
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? ](*,)
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? ](*,)
0
Best Answer
-
MARK markes the record according to the primary key fields set at the moment you mark it.
This is the same as with FIND, MODIFY, DELETE, RENAME.
The mystery of your test code lies in the lineREPEAT message(test.Desc); UNTIL NEXT = 0;
which should readREPEAT message(test.Desc); UNTIL test.NEXT = 0;
With this change your results will be as expected.5
Answers
-
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
Pargesoft0 -
MARK markes the record according to the primary key fields set at the moment you mark it.
This is the same as with FIND, MODIFY, DELETE, RENAME.
The mystery of your test code lies in the lineREPEAT message(test.Desc); UNTIL NEXT = 0;
which should readREPEAT message(test.Desc); UNTIL test.NEXT = 0;
With this change your results will be as expected.5 -
Hi Andiwan
Please read the initial statement of my answer above, followed by ufuk's explanation of what the whole block of code does.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions