Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

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

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
PeterdeB
Asked:
PeterdeB
1 Solution
 
MerijnBSr. Software EngineerCommented:
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
 
PeterdeBAuthor Commented:
Thank you
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now