Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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