Solved

ignoring all spaces with trim function?

Posted on 2003-11-24
3
295 Views
Last Modified: 2010-04-05
Hi

I am trying to write to a text file from the input that the user enters in a maskeditbox, the user enters a numbers but if they leave blank spaces the problem is that the blank spaces also appear in my text file, so when the user enters 555/222/111 its fine but if a user enters
55   / 2  / 1 then the spaces also appear in my text file; i have tried to use trim to solve this problem but it does not work for this situation, my current code is

assignfile(txt, '/home/user/test2.txt');
rewrite(txt);

S:= ' number' + maskedit1.text ;
S:=Trim(s);
WriteLn(txt,s);
closefile(txt);

also is it possible to get rid of the spaces just in the maskedit1? As if i get rid of all the spaces then the number bit will be stuck with the input the user entered such as
number55/2/1  when is i want number 55/2/1  ,

thanks in advance .

0
Comment
Question by:itektas
3 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 30 total points
Comment Utility
var s : string; i : integer;

s := '';
for i := 1 to Length(maskedit1.text) do begin
  if maskedit1.text[i] > #32 then s := s + maskedit1.text[i];
end;
maskedit1.text := s;

...now write to file etc...

Geoff M.
0
 

Author Comment

by:itektas
Comment Utility
thanks! :)
0
 
LVL 19

Expert Comment

by:Limbeck
Comment Utility
Why not use:

maskedit1.text:=StringReplace(maskedit1.text,' ','',[rfReplaceAll]);

Less code this way ;)

Ed
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now