Solved

Code that makes the characters of a line uPpERcAse aND loWErCasE sCramblEd

Posted on 2007-12-06
2
177 Views
Last Modified: 2010-04-21
Hi all

I have created a program which i use for making MSN names reverse [i.e. Frank becomes knarF] and now I want it to also randomize upper and lowercase characters to make it even less readable, so that Frank becomes kNaRf for instance, I do use spaces and lines from lyrics by the way, can anyone help?

Thank you


The code is:
======
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, strutils, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private

    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  edit1.Text:= '';
  edit2.Text:= '';
end;

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;

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



end.
0
Comment
Question by:PeterdeB
2 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 500 total points
ID: 20419642
see this example:
function MixCase(InStr: string): string;

var i: integer;

begin

 Randomize();

 for i := 1 to Length(InStr) do

  if Random(2) = 1 then

   result := result + LowerCase(InStr[i])

  else

   result := result + UpperCase(InStr[i]);

end;

Open in new window

0
 

Author Closing Comment

by:PeterdeB
ID: 31413140
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

20 Experts available now in Live!

Get 1:1 Help Now