MARK function

Hi all, I am trying to filter a cust. ledger entry for several customers. I can use something like this: CustLedEnt.SETFILTER(“Customer No.”, ‘10000’,‘20000’); Can i use MARK(TRUE) to achieve the same results? my assumptions are that i can use MARK() to mark records based on several filters, then filter for the marked records. what i have written is : CustLedEnt.RESET; CustLedEnt.SETRANGE(“Customer No.”, ‘10000’); CustLedEnt.MARK(TRUE); CustLedEnt.SETRANGE(“Customer No.”); CustLedEnt.SETRANGE(“Customer No.”, ‘20000’); CustLedEnt.MARK(TRUE); CustLEdEnt.MARKEDONLY; After i have done this, i realised that only customer 20000 is marked, and not customer 10000… tq

MARK will mark the current record. In your code example you use SETRANGE, but that in itself does not change the current record. You need to do something like the following.


CustLedEnt.RESET;
CustLedEnt.SETRANGE("Customer No.",'10000');
IF CustLedEnt.FIND('-') THEN
  REPEAT
    CustLedEnt.MARK(TRUE);
  UNTIL CustLedEnt.NEXT = 0;
 

By the way, if the number of customers that you are trying to filter is not too big you can construct an argument to SETFILTER.


FilterString := '10000|20000';
CustLedEntry.SETFILTER("Customer No.",FilterString);
 

The creation of FilterString above is very simple but could certainly be more complex; you are, however, limited by the maximum length of text variables.

not only are you limited to a string of 250 characters, you are also limited to 12 parameters, as this is the limit of the SETFILTER function… i am not sure if this is a liimit on all of navision’s function… jordan

i have tried, and it does not work… if you check the navision on-line manual, you will see that the MARK function does not require any loops to mark the records in a table, but instead what i uses is sorting. before the mark is used you need to activate a key. but that would make the MARK function not very flexible to use…

quote:


Originally posted by jordi79: not only are you limited to a string of 250 characters, you are also limited to 12 parameters, as this is the limit of the SETFILTER function… i am not sure if this is a liimit on all of navision’s function… jordan


I believe this limit of 12 params should be interpreted as 2+10, instead of simply 12. The first two params are the Field you want to place a filter on, and a filter expression that can contain replacement fields. I assume SetFilter uses the same (internal) code as StrSubstNo for handling these replacement fields. In that case, it makes sense that the limitations of StrSubstNo, i.e. a maximum of 10 replacement fields, also applies to SetFilter. A function can have many more params in C/SIDE. Kind regards, Jan Hoek Weha Automatisering BV Woerden - The Netherlands

but that does still does not solve the problem in applying multiple filters to the same field in a table? i have tried to use the MARK() function, but i found that it is not that easy to use this function… has anyone attempted to apply mulitple filters to the same field in a table?

The code has a couple of errors: CustLedEnt.RESET; CustLedEnt.SETRANGE(“Customer No.”, ‘10000’); // Here you should add a find IF CustLedEnt.FIND(’-’) THEN CustLedEnt.MARK(TRUE); CustLedEnt.SETRANGE(“Customer No.”); CustLedEnt.SETRANGE(“Customer No.”, ‘20000’); // Here you should add a find IF CustLedEnt.FIND(’-’) THEN CustLedEnt.MARK(TRUE); //Remove the customer no filter CustLedEnt.SETRANGE(“Customer No.”); CustLEdEnt.MARKEDONLY; Now it should work…Regards Alfonso Pertierra (Spain)apertierra@teleline.es

Hi I Think the 12 paramater limit for setfilter is only relevent when you use rec.SETFILTER(x,’%1|%2|%3|…’,parm1,parm2,…). But not in Integer.RESET; Integer.SETFILTER(Number, ‘1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20’); MESSAGE(FORMAT(Integer.COUNT)); Where ‘1|2|3…’ Could also be a text variable. The limit of text 250 characters (1024 in 2.65 onwards) is a problem. Alfonso’s solution should work but if you are using a large table make sure you use a good key when Marking and displaying you records. Paul Baxter Edited by - triff on 2001 Dec 06 12:21:27

Just for the record: In Jordi79’s original note, there is the statement that after doing two CustLdeEnt.MARK functions on two ranges that only the second MARK was active. As I read the example code, when the CustLEdEnt.MARKEDONLY statement is executed, the second SETRANGE is still active, thus filtering out all the MARKed records within the first range. In other words, if you preceed the CustLEdEnt.MARKEDONLY statement with CustLEdEnt.SETRANGE(“Customer No.”), you would be able to see all the MARKed records. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner

quote:


[b]David wrote:[/] Just for the record: In Jordi79’s original note, there is the statement that after doing two CustLdeEnt.MARK functions on two ranges that only the second MARK was active. As I read the example code, when the CustLEdEnt.MARKEDONLY statement is executed, the second SETRANGE is still active, thus filtering out all the MARKed records within the first range. In other words, if you preceed the CustLEdEnt.MARKEDONLY statement with CustLEdEnt.SETRANGE(“Customer No.”), you would be able to see all the MARKed records.


Just for the record: the fail was not only the setrange, but that he was not doing also a find after the setrange, so he could be marking whatever record but the one he was wanting to… Regards, Alfonso Pertierra (Spain)apertierra@teleline.es

I haev tried it out, the proper working code should look like below: CustLedEnt.RESET; CustLedEnt.SETCURRENTKEY(“Customer No.”); CustLedEnt.SETRANGE(“Customer No.”, ‘10000’); IF CustLedEnt.FIND(’-’) THEN REPEAT CustLedEnt.MARK(TRUE); UNTIL CustLedEnt.NEXT = 0; CustLedEnt.SETRANGE(“Customer No.”, ‘20000’); IF CustLedEnt.FIND(’-’) THEN REPEAT CustLedEnt.MARK(TRUE); UNTIL CustLedEnt.NEXT = 0; CustLedEnt.SETRANGE(“Customer No.”); CustLedEnt.MARKEDONLY(TRUE); CustLedEnt.FIND(’-’); REPEAT BEGIN CustLedEnt.test := 1; CustLedEnt.MODIFY; END UNTIL CustLedEnt.NEXT = 0;

Thanks for sharing the correct answer. That makes this thread more useful for future reference. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner

Could this not be written alot simpler: CustLedEnt.RESET; CustLedEnt.SETCURRENTKEY(“Customer No.”); CustLedEnt.SETRANGE(“Customer No.”, ‘10000’); CustLedEnt.MODIFYALL(test,1); CustLedEnt.SETRANGE(“Customer No.”, ‘20000’); CustLedEnt.MODIFYALL(test,1); Or, using SETFILTER (with the Limitations from above): CustLedEnt.RESET; CustLedEnt.SETCURRENTKEY(“Customer No.”); CustLedEnt.SETFILTER(“Customer No.”, ‘10000|20000’); CustLedEnt.MODIFYALL(test,1); Chris Krantz NCSD,NCSQL,MCSD,MCSE Microforum Inc. Toronto, Ontario, Canada

if you read the previous messages that was posted, there was a reason as to why the setfilter function is not used. the setfilter function has parameter limitations of 12 and not to mention a text limitation of 250 characters. to bypass this limitation a MARK function is used instead.