Solved

Basic's Trim() function in Delphi 1.0?

Posted on 1998-11-07
6
251 Views
Last Modified: 2010-05-18
I would like to know if there is a function like Basic's
Trim() to get rid of spaces in Delphi 1.0?
0
Comment
Question by:poodle
6 Comments
 
LVL 1

Expert Comment

by:ow
ID: 1346021
 Hi poodle,

in unit sysutils you find:

{ Trim trims leading and trailing spaces and control characters from the  given string. }
function Trim(const S: string): string;

{ TrimLeft trims leading spaces and control characters from the given  string. }
function TrimLeft(const S: string): string;

{ TrimRight trims trailing spaces and control characters from the given  string. }
function TrimRight(const S: string): string;

regards
  ow

0
 
LVL 1

Expert Comment

by:EmmDieh
ID: 1346022
ow: that's correct for delphi >= 3 (2?), but not
for Delphi 1.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346023
Here is the way to do it in Delphi1,2

as a procedure...

procedure Trim(var Str : string);
begin
  while Str[1] = ' ' do
    Delete(Str, 1,1);
  while Str[Length(str)] = ' ' do
    Delete(Str, Length(Str)-1, 1);
end;

as a function...

function Trim(Str : String):String;
begin
  Result := Str;
  while Result[1] = ' ' do
    Delete(Result, 1,1);
  while Result[Length(Result)] = ' ' do
    Delete(Result, Length(Result)-1, 1);
end;

To use them just do as follows...

var
  S : string;
begin
  S := '   Hello World   ';
  //To use the procedure do this.....
  Trim(s);
  //If you want to use the function just do this...
  S := Trim(s);
  caption := s;
end;

Cheers,
Viktor
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Expert Comment

by:ow
ID: 1346024
 Hi poodle,

I am really sorry, but my answer is not correct.
As Emmdieh says, these routines are not implemernted in Delphi 1.
Unfortunatley I looked at the wrong source file.

So please reject my answer and give the points to Victor, as he has shown the right way.

Regards
  ow
0
 

Author Comment

by:poodle
ID: 1346025
I rejected ow, but how can I accept vitornet's answer?
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1346026
You can now accept my answer... 10x

Cheers,
Viktor
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

19 Experts available now in Live!

Get 1:1 Help Now