TRIM function

lloydflloydf Member Posts: 73
Hi there
Does anyone know if it is possible to TRIM a string from trailing and leading spaces?

Thanks

LLoyd

Comments

  • Revolution1210Revolution1210 Member Posts: 161
    You can do this using the C/AL function DELCHR

    To delete leading spaces from a string:
    String := DELCHR(String,'<',' ');
    

    To delete trailing spaces from a string:
    String := DELCHR(String,'>',' ');
    

    To delete both leading and trailing spaces:
    String := DELCHR(String,'<>',' ');
    
    Ian

    www.NextEqualZero.com
    A technical eye on Dynamics NAV
  • lloydflloydf Member Posts: 73
    Thanks Ian, it works a treat!
  • DenSterDenSter Member Posts: 8,305
    traling spaces will be trimmed automatically from text type table fields if you VALIDATE the value.
  • KowaKowa Member Posts: 923
    String := DELCHR(String,'<>',' ');
    
    Since "spaces" is the default for the second parameter,
    String := DELCHR(String,'<>');
    
    will also work.
    Kai Kowalewski
Sign In or Register to comment.