Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…

830 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