Error in DELCHR

QuivelusQuivelus Member Posts: 24
Hi,


Recently i tried to use the DELCHR function. The C/Side reference guide says following:

- I am currently working in version 4 SP2

Text constants:

Text000: 'Windy Solutions'
Text001: '>%1<, is transformed to: >%2<'

C/AL:

String := Text000;
Where := '<>';
Which := 'Ws';
NewString := DELCHR(String, Where, Which);
MESSAGE(Text001, String,NewString);

It says result will be:

>Windy Solutions<, is transformed to: >indy Solution<


Why is this. I would think it should be: >Windy Solutions<, is transformed to: >Ws<. I also tried the same with: Where := '=';
This gives the same result as with Where := '<>'...

Is this a bug or am i doing something wrong?
Bohr-ing.

Comments

  • Thomas_Hviid_ThornThomas_Hviid_Thorn Member Posts: 92
    Hej Quivelus,

    The On-Line help also states that
    Include...
    To have the system delete any...

    = Character in String that matches a character in Which. (default)

    < Leading character in String that matches a character in Which.

    > Trailing character in String that matches a character in Which.

    That is
    < removes only the leading character
    > removes only the trailing character

    Try using 'Windys WSolutions' => 'indys WSolution'
    With Kind Regards
    Thoms Hviid Thorn
  • QuivelusQuivelus Member Posts: 24
    True,


    Ok, if it works like this, then i get it. I thought '<>' stood for 'different from'.


    Tx.
    Bohr-ing.
  • krikikriki Member, Moderator Posts: 9,110
    If you want to keep 0123456789 in a string in stead of deleting them, use this:
    txtCharsToKeep := '0123456789';
    txtString := DELCHR(txtString,'=',DELCHR(txtString,'=',txtCharsToKeep));
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • QuivelusQuivelus Member Posts: 24
    My purpose was to delete all chars that where not in the string (parameter). Guess i should use another function for this purpose.
    Bohr-ing.
  • krikikriki Member, Moderator Posts: 9,110
    Quivelus wrote:
    My purpose was to delete all chars that where not in the string (parameter). Guess i should use another function for this purpose.
    The DELCHAR(DELCHAR I wrote before just does that.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • QuivelusQuivelus Member Posts: 24
    Indeed, guess i read your reply to swiftly and didn't notice the repetition of the DELCHR function. I now see how it works, tx Kriki.

    P.S.: How do i close this subject? Or is this done automatically?
    Bohr-ing.
  • SavatageSavatage Member Posts: 7,142
    Edit the subject in your original post and add [Solved]
  • bekiobekio Member Posts: 204
    Good Topic kriki,

    It was very helpfull for me!
Sign In or Register to comment.