?
Solved

ignoring all spaces with trim function?

Posted on 2003-11-24
3
Medium Priority
?
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 120 total points
ID: 9810548
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
ID: 9810829
thanks! :)
0
 
LVL 19

Expert Comment

by:Limbeck
ID: 9823273
Why not use:

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

Less code this way ;)

Ed
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 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