Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 849521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:07:00+00:00 2026-05-15T07:07:00+00:00

Here is my attempt to solve the About.com Delphi challenge to un-camel-case a string

  • 0

Here is my attempt to solve the About.com Delphi challenge to un-camel-case a string.

unit challenge1;

interface

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

type
   check = 65..90;
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  var s1,s2 :string;
  int : integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  checks : set of check;
begin
  s1 := edit1.Text;
  for i := 1 to 20  do
  begin
    int  :=ord(s1[i]) ;
    if int in checks then
      insert('  ',s1,i-1);
  end;
  showmessage(s1); 
end;

end.

check is a set that contains capital letters so basically whenever a capital letter is encountered the insert function adds space before its encountered (inside the s1 string), but my code does nothing. ShowMessage just shows text as it was entered in Edit1. What have I done wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:07:01+00:00Added an answer on May 15, 2026 at 7:07 am

    You’re correct that check is a set, but you haven’t assigned any value to it yet, so its value is indeterminate. There are not the characters you expect in it, so the in test probably always fails. (Didn’t the compiler warn you that you hadn’t assigned anything check yet?)

    You don’t really want to define check as a subrange type. Rather, you should replace check with the built-in TSysCharSet type, which is a set of characters. Then assign check like this:

    check := ['A'..'Z'];
    

    Furthermore, rather than check the numeric value of the string with int and Ord, just use the Char values directly: if s1[i] in check. You’ll also want to use the Length function so you process the entire string instead of assuming that the input will always be exactly 20 characters long. You’ll also want to store the result into something other than s1 since, as Caldon points out, you don’t want to modify it at the same time that you’re still reading more characters from it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Clojure algorithm to solve the problem posed here: http://spin.atomicobject.com/2011/05/31/use-clojure-to-move-drugs-a-programming-challenge/ and
Here is my attempt in jquery that kind of works but something is going
How to dynamically change the timeout of the cycle plugin here is my attempt
I'm trying to calculate time blocks from given date range. Here's my attempt: <?php
Here is my first attempt at validating XML with XSD. The XML file to
Here's the flow I'm looking for for authentication: Attempt to pull in the user's
Here in stackoverflow, if you started to make changes then you attempt to navigate
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
I'm getting this error: -[NSCFArray insertObject:atIndex:]: attempt to insert nil Here is the .m
I'm after a simple stored procedure to drop tables. Here's my first attempt: CREATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.