program that reverses text

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
PeterdeBAsked:
Who is Participating?
 
MerijnBSr. Software EngineerCommented:
like this:

procedure TForm1.Button1Click(Sender: TObject);
var
line1, line2: string;
begin
line1:= edit1.Text;
line1 := Reverse (line1);
end;
0
 
MerijnBSr. Software EngineerCommented:
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
 
PeterdeBAuthor Commented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
PeterdeBAuthor Commented:
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
 
imitchieCommented:
or..

procedure TForm1.Button1Click(Sender: TObject);
var
line1, line2: string;
begin
line1:= Reverse (edit1.Text);
end;
0
 
imitchieCommented:
actually, i think you typed the "-' in your question misleading MerijnB. this is enough

line1:= ReverseString(edit1.Text);
0
 
rfwoolfCommented:
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
 
MerijnBSr. Software EngineerCommented:
huh? strange answer to accept ??
0
 
rfwoolfCommented:
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
 
PeterdeBAuthor Commented:
Sowwy for my short comments and feedback my girlfriend just left me:(
0
 
rfwoolfCommented:
Thanks guys. That's much better. Don't you agree, MerjinB?
0
 
MerijnBSr. Software EngineerCommented:
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
 
PeterdeBAuthor Commented:
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
 
rfwoolfCommented:
Hey thanks PeterdeB. Sorry about your girlfriend. It's all good now :) Thanks. Hope to see you again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.