SETFILTER with wildchar and a parenthesis () in filter value

gmtorinogmtorino Member Posts: 2
Anyone know how to... ?

I have to filter all records where a field (eg. description in Item) contains the following value: (E)

The parenthesis "(" is part of the value but after trying diffent way I didn't get out of it.
The code would look like this:
gRecItem.RESET ;

gRecItem.SETFILTER(gRecItem.Description,'*(E)*') ;

IF gRecItem.FINDFIRST THEN
  REPEAT ;
   gRecItem.Extra := 'E' ;
   gRecItem.MODIFY ;
  UNTIL gRecItem.NEXT = 0 ;

MESSAGE('Done') ;

Comments

  • SavatageSavatage Member Posts: 7,142
    is there a space around the (E)?

    then * ?E? *
  • MaximusMaximus Member Posts: 105
    Hi,

    have you tried: gRecItem.SETFILTER(gRecItem.Description,'*%1*','(E)') ;

    or: gRecItem.SETFILTER(gRecItem.Description,%1,'*(E)*') ;?

    you could also try this:

    gRecItem.RESET ;
    IF gRecItem.FINDSET(TRUE,FALSE) THEN REPEAT
    IF STRPOS(gRecItem.Description,'(E)') <> 0 THEN BEGIN
    gRecItem.Extra := 'E' ;
    gRecItem.MODIFY ;
    END:
    UNTIL gRecItem.NEXT = 0 ;

    MESSAGE('Done') ;
  • garakgarak Member Posts: 3,263
    Try this:
    setfilter(Description,'%1|%2|%3|%4','@*(E)*','@*( E)*','@*(E )*','@*( E )*');
    //here a loop if needed
    

    The @ you can leave if you need a upper E. If you search for e/E set the @.
    If you see, the code filter also Descriptions where a space is between the letters. If there is a other letter (not space) between this characters, you can also use harry's solution (@*(?E?)*).

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.