Solved

Basic's Trim() function in Delphi 1.0?

Posted on 1998-11-07
6
257 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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