Problem with DELCHR

poppinspoppins Member Posts: 647
edited 2013-10-06 in NAV Three Tier
Hi everyone,
I am using an xmlport to export decimal fields into a text file.
For the decimals in thousands, for exmple 1 758.245, the generated text file shows 1ÿ758.245 :(
I tried to remove the blank space by writing the following code:
        amount:=FORMAT(totalAmount);
        FOR K := 1 TO strlen(amount) DO
        BEGIN
              IF ((amount[K] <> '0') AND (amount[K] <> '1') AND (amount[K] <> '2') AND (amount[K] <> '3') AND
              (amount[K] <> '4') AND (amount[K] <> '5') AND (amount[K] <> '6') AND (amount[K] <> '7') AND
              (amount[K] <> '8') AND (amount[K] <> '9')
             ) THEN 
               BEGIN
                      NotNum := amount[K];
                      amount:= DELCHR(amount,'=',NotNum);
               END;
        END;
        
but it didn't work :(:(
What shall I do???

Answers

  • KishormKishorm Member Posts: 921
    Try FORMAT(TextAmount,0,1)
  • poppinspoppins Member Posts: 647
    Kishorm wrote:
    Try FORMAT(TextAmount,0,1)
    Thanks for your answer....but I tried it and it didn't work
  • poppinspoppins Member Posts: 647
    I found the following code in mibuso:
    txtCharsToKeep := '0123456789';
    txtString := DELCHR(txtString,'=',DELCHR(txtString,'=',txtCharsToKeep));
    
    but I didn't know how to declare txtString in C/AL Globals...is it a string or what?
  • KishormKishorm Member Posts: 921
    Strange, the FORMAT should work.

    However you can use the code you have found, both txtCharsToKeep and txtString are both string variable. Also you need to add '.' at the end of the txtCharsToKeep otherwise it will strip out your decimal point.
  • poppinspoppins Member Posts: 647
    Kishorm wrote:
    Strange, the FORMAT should work.

    However you can use the code you have found, both txtCharsToKeep and txtString are both string variable. Also you need to add '.' at the end of the txtCharsToKeep otherwise it will strip out your decimal point.
    Indeed, I found it strange too and I don't know why it didn't work :?:
    Anyway, I declared the txtCharsToKeep as string and it worked...
    Thanks a lot Kishorm :D
Sign In or Register to comment.