Filter as a variable

NabucoNabuco Member Posts: 65
Hi all
Being somewhat novice in C/SIDE i have a Little problem.

Having a Var - code120 - value: <>TRACK

When this Var has a content I wish to extend it to exclude all blanks. Therefore I has coded:

IF Var <>'' THEN
Var := Var + '|' + '<>''';

Giving the result: <>TRACK|<>'

Missing one ' as the last - why is that - does anyone know the solution?

Answers

  • KishormKishorm Member Posts: 921
    Hi

    2 problems here...

    First, if you want a single quote within a string you put 2 single quotes, so instead of ''' you would have '''' therefore to have a string of 2 single quotes you would have 6 consecutive single quotes - 1 start quote, 2 quotes for the first single quote, 2 more quotes for the second single quote and then a final quote to close the string.

    Second, if you want to exclude blanks then you should have an AND (&) not an OR (|)

    Therefore your code should be....

    IF Var <>'' THEN
    Var := Var + '&' + '<>'''''; // that's 5 quotes at the end and 1 quote just before the <>

    Giving the result: <>TRACK&<>''

    Regards
    Kishor
  • vaprogvaprog Member Posts: 1,141
    You have to write two single quotation marks within a string literal to get one in the data. This is C/AL's way of quoting them. Otherwise it was treated as the closing string delimiter.

    Also you will want to think again about your filter expression. Does it really do what you intend (because it will not do what you wrote you want to achieve).
Sign In or Register to comment.