Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Basic's Trim() function in Delphi 1.0?

Posted on 1998-11-07
6
Medium Priority
?
274 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 100 total points
ID: 1346026
You can now accept my answer... 10x

Cheers,
Viktor
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

773 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