Solved

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

Posted on 2007-12-06
2
176 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

19 Experts available now in Live!

Get 1:1 Help Now