Delete space in a string

iqbalmad
Member Posts: 180
amttext := FORMAT(amt,0);
--- DELCHR(amttext) ---
i am using this delchr to delete the spaces that is found in my amount.
Before After
389 510 >> 389510
But this is not the case. Can someone tell me y?
--- DELCHR(amttext) ---
i am using this delchr to delete the spaces that is found in my amount.
Before After
389 510 >> 389510
But this is not the case. Can someone tell me y?
0
Comments
-
NewString := DELCHR(String [, Where] [, Which])
Try to give the WHERE and WHICH parameter.
NewString := DELCHR(Amttext, '=', ' ');0 -
that too doesnt work jhenav0
-
x := ' 389 510 456 65'; y := delchr(x,'=',' '); //NOT '', use SPACE in ''
RegardsDo you make it right, it works too!0 -
i have tried this too.. still doesnt work..
ps: my amount is a decimal field.0 -
:-) than you mean that you want to print the number without thousend separator.... ;-)0
-
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
RegardsDo you make it right, it works too!0 -
yes kine.. i am sending my decimal field in a txt file.. and i want to remove the thousand separators.. i no i can change my local settings for that..
but users have this as their local settings.. and the bank wants the numbers without the <space> separators.0 -
iqbalmad wrote:yes kine.. i am sending my decimal field in a txt file.. and i want to remove the thousand separators.. i no i can change my local settings for that..
You format the Amount and delete the BLANKS.
Combinate both functions like:
ValueToWriteInTheTextFile := delchr(format(Amount),'=',' ');Do you make it right, it works too!0 -
hi garak.
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ÿ6800 -
hi guys,
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.0 -
What about using while loop to pad the string by 0 from left? Or some function for that? Or fill char in the format?0
-
t_myString := 'some text';
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 forum0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions