Adding to a string

sabzamsabzam Member Posts: 1,149
Dear All,

I have got a text variable let's say named Desc. Now I want to add ' AND ' (the word and; preceded and followed by a space) and here is the code:

INSSTR(Desc, ' AND ', 2)

For some reason the spaces are not being added.

Could anyone help me out?

Answers

  • krikikriki Member, Moderator Posts: 9,110
    use:
    Desc := Desc + ' AND ';
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • McClaneMcClane Member Posts: 40
    Tested your code and can´t verify the problem. Works fine :-k
  • sabzamsabzam Member Posts: 1,149
    INSSTR(Desc, ' AND ', 2)

    Does it make a difference if instead of ' AND ' there is a variable with the same contents (I need a variable because the word to paste will differ according to particular conditions)?
  • sabzamsabzam Member Posts: 1,149
    I have just discovered that the problem was that I was using a variable of Type code, appartently the spaces were not being accepted. As soon as I changed from type code to type text the problem has been solved.
  • kinekine Member Posts: 12,562
    Yes, the CODE data type is automatically trimming the value by removing leading and trailing empty spaces.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.