Stop?! Is the BEFORE variable a decimal or a text? Do you whish only delete the separetors if it is a decimal and in your local settings this separators exist?
So. what is X (BEFORE) it is text? Sure????.
What is y (After) text or decimal? You say u need decimal, ok, no problem.
x := ' 389 510 456 65'; //x is text
evaluate(y,delchr(x,'=',' ')); //y is decimal
FormatAmtNMC(AmountToFormat : Decimal;VAR text5 : Text[16])
len := STRLEN(FORMAT(AmountToFormat,0));
IF len = 1 THEN text5 := '000000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 2 THEN text5 := '00000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 3 THEN text5 := '0000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 4 THEN text5 := '000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 5 THEN text5 := '00000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 6 THEN text5 := '0000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 7 THEN text5 := '000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 8 THEN text5 := '00000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 9 THEN text5 := '0000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 10 THEN text5 := '000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 11 THEN text5 := '00000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 12 THEN text5 := '0000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 13 THEN text5 := '000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 14 THEN text5 := '00' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 15 THEN text5 := '0' + DELCHR(FORMAT(AmountToFormat),'=',' ');
Result on screen : 00000002 207 680
Result on txt file : 00000002ÿ207ÿ680
Comments
Try to give the WHERE and WHICH parameter.
NewString := DELCHR(Amttext, '=', ' ');
Regards
ps: my amount is a decimal field.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
So. what is X (BEFORE) it is text? Sure????.
What is y (After) text or decimal? You say u need decimal, ok, no problem.
Regards
but users have this as their local settings.. and the bank wants the numbers without the <space> separators.
You format the Amount and delete the BLANKS.
Combinate both functions like:
ValueToWriteInTheTextFile := delchr(format(Amount),'=',' ');
This is my function
FormatAmtNMC(AmountToFormat : Decimal;VAR text5 : Text[16])
len := STRLEN(FORMAT(AmountToFormat,0));
IF len = 1 THEN text5 := '000000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 2 THEN text5 := '00000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 3 THEN text5 := '0000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 4 THEN text5 := '000000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 5 THEN text5 := '00000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 6 THEN text5 := '0000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 7 THEN text5 := '000000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 8 THEN text5 := '00000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 9 THEN text5 := '0000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 10 THEN text5 := '000000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 11 THEN text5 := '00000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 12 THEN text5 := '0000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 13 THEN text5 := '000' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 14 THEN text5 := '00' + DELCHR(FORMAT(AmountToFormat),'=',' ');
IF len = 15 THEN text5 := '0' + DELCHR(FORMAT(AmountToFormat),'=',' ');
Result on screen : 00000002 207 680
Result on txt file : 00000002ÿ207ÿ680
i managed to find another similar topic:
viewtopic.php?f=5&t=36319&hilit=decimal
since my client does not have decimal places in amounts, i am using
IF len = 1 THEN text5 := '000000000000000' + FORMAT(AmountToFormat, 0, '<Integer>');
thanks for the guidance.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
t_NewString := FORMAT(t_myString,0,STRSUBSTNO('<text,%1><filler character,0>',20))
t_NewString is now: '00000000000some text'
STRLEN(t_NewString) = 20
t_NewString := FORMAT(t_myString,0,STRSUBSTNO('<text,%1><filler character,'.'>',20))
t_NewString is now: '...........some text'
STRLEN(t_NewString) = 20
Another solution:
Fill trailing
t_NewString := t_myString + PADSTR('',20 - STRLEN(t_myString),'.');
t_NewString is now: 'some text...........'
Fill leading
t_NewString := PADSTR('',20 - STRLEN(t_myString),' ') + t_myString;
t_NewString is now: '...........some text'
* had to use . instead og space since spaces gets trimmed in the forum