Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

program that reverses text

Posted on 2007-11-14
15
Medium Priority
?
193 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
[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
  • 4
  • 4
  • 4
  • +1
15 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 20283923
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
ID: 20284297
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
ID: 20284306
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
Independent Software Vendors: 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 19

Accepted Solution

by:
MerijnB earned 1000 total points
ID: 20284321
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
ID: 20284947
or..

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

Expert Comment

by:imitchie
ID: 20284958
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 1000 total points
ID: 20288190
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
 
LVL 19

Expert Comment

by:MerijnB
ID: 20335159
huh? strange answer to accept ??
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20335204
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
ID: 31409229
Sowwy for my short comments and feedback my girlfriend just left me:(
0
 
LVL 13

Expert Comment

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

Expert Comment

by:MerijnB
ID: 20349833
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
ID: 20462299
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
ID: 20463504
Hey thanks PeterdeB. Sorry about your girlfriend. It's all good now :) Thanks. Hope to see you again.
0

Featured Post

Independent Software Vendors: 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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 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