?
Solved

How to increase a string ?

Posted on 2003-03-03
3
Medium Priority
?
137 Views
Last Modified: 2010-04-04
for example , the initial string is 'aaa', the final string is 'aba', i want to increase the initial sting 'aaa' letter by letter to the final string 'aba',
like this:

aaa->aab->aac->...->aaz->aba

the string's low and up case is not required.
0
Comment
Question by:Sam80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
SimesA earned 200 total points
ID: 8062857
var
  i,p: integer;
  str: string;
begin
  str := 'aaa';
  p := length(str);
  while str <> 'aba' do begin
    if str[p] <> 'z' then
      str[p] := char(ord(str[p])+1)
    else begin
      str[p] := 'a';
      dec(p);
      str[p] := char(ord(str[p])+1)
    end;
    Listbox1.Items.Add(str);
  end;
end;
0
 
LVL 6

Expert Comment

by:zebada
ID: 8062873
You can also use:
  Inc(str[p])
instead of
  str[p] := char(ord(str[p])+1)

Regards
Paul
0
 
LVL 1

Expert Comment

by:rfedyk
ID: 8063321
Here's another way that emulates modulo 26 arithmetic (like an extended form of HEX)

str:='aaa';
carry:=false;
for ol:=3 downto 1 do //change 1 to 2 if only 2 characters
 for l:= 1 to 26 do   //are required to be changed
   begin
    if carry then
     str[ol+1]:='a';
    str[ol]:=char(l+96);
    carry:=(l mod 26)=0;
   end;

Regards
Roger Fedyk
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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