Solved

program that reverses text

Posted on 2007-11-14
15
182 Views
Last Modified: 2010-04-21
Does anyone know the delphi code to reverse a line of text that I enter in it like so:

-I type this line

it becomes

-enil siht epyt i

thx in advance
0
Comment
Question by:PeterdeB
  • 4
  • 4
  • 4
  • +1
15 Comments
 
LVL 19

Expert Comment

by:MerijnB
Comment Utility
if you use the unit StrUtils there is a function called ReverseString() you can use.
If you want to keep the '-' in front use something like:

uses StrUtils;

...

function Reverse(InStr: string): string;
begin
 result := '';

 if Length(InStr) = 0 then
  exit;

 if InStr[1] = '-' then
 begin
  result := '-';
  Delete(InStr, 1, 1);
 end;

 result := LowerCase(result + ReverseString(InStr));
end;
0
 

Author Comment

by:PeterdeB
Comment Utility
Hey thank you, i went to do a search for this, but it is included with delphi [the unit]. I am trying to make it work now
0
 

Author Comment

by:PeterdeB
Comment Utility
procedure TForm1.Button1Click(Sender: TObject);
var
line1, line2: string;
begin
line1:= edit1.Text;
Reverse (line1);
end;

it compiles correctly but does not change the text
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 250 total points
Comment Utility
like this:

procedure TForm1.Button1Click(Sender: TObject);
var
line1, line2: string;
begin
line1:= edit1.Text;
line1 := Reverse (line1);
end;
0
 
LVL 25

Expert Comment

by:imitchie
Comment Utility
or..

procedure TForm1.Button1Click(Sender: TObject);
var
line1, line2: string;
begin
line1:= Reverse (edit1.Text);
end;
0
 
LVL 25

Expert Comment

by:imitchie
Comment Utility
actually, i think you typed the "-' in your question misleading MerijnB. this is enough

line1:= ReverseString(edit1.Text);
0
 
LVL 13

Assisted Solution

by:rfwoolf
rfwoolf earned 250 total points
Comment Utility
errrrrrr what the Author wants you to tell him/her is this:

procedure TForm1.Button1Click(Sender: TObject);
var
  line1, string;
begin
  line1:= edit1.Text;
  line1 := Reverse (line1);
 ***** Edit1.text := line1;  <--- This line!
end;

Or am I off the mark?
0
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

 
LVL 19

Expert Comment

by:MerijnB
Comment Utility
huh? strange answer to accept ??
0
 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
I see... PeterdeB, although you have accepted the correct solution because what I typed was the correct code that would compile and work, I am undeserving of (all?) the points.
I will not personally object if someone goes to admin to get the points re-assigned. Although it was probably an innocent mistake, it is not fair :p
0
 

Author Closing Comment

by:PeterdeB
Comment Utility
Sowwy for my short comments and feedback my girlfriend just left me:(
0
 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
Thanks guys. That's much better. Don't you agree, MerjinB?
0
 
LVL 19

Expert Comment

by:MerijnB
Comment Utility
yeps :)

I don't really mind about the points, more like a comment to the question asker to pay attention when assigning the points
0
 

Author Comment

by:PeterdeB
Comment Utility
heey guys sowwy like I said I had too much things on my mind and still have tell me  if I stil need to change anything :(
0
 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
Hey thanks PeterdeB. Sorry about your girlfriend. It's all good now :) Thanks. Hope to see you again.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

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

15 Experts available now in Live!

Get 1:1 Help Now