Closed Thread
Results 1 to 4 of 4

Thread: More efficient way of writing this Code:

  1. #1
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    More efficient way of writing this Code:

    Hi all.

    I was just wondering if there is a more efficient way of writing this:

    Case Nextguessedletter of

    'A': Count:= 1
    'B': Count:= 2
    'C' etc
    'D' etc
    'E'
    'F'
    'G'
    'H'
    'I'
    'J'
    'K'
    'L'
    'M'
    'N'
    'O'
    'P'
    'Q'
    'R'
    'S'
    'T'
    'U'
    'V'
    'W'
    'X'
    'Y'
    'Z'

    The thing is, I want to store the letters of the alphabet into an array 1..26.

    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: More efficient way of writing this Code:

    Ok. Nvm. I found out how to do it. For anyone who wants to know:

    I just used this function called Succ. It takes the next character in series. Ie:

    Succ('A') will give: B
    Succ('2') will give: 3

    Thanks

  4. #3
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: More efficient way of writing this Code:

    Check out the Ord() function as well. Ord(val)-Ord('A')+1.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  5. #4
    Rustix666's Avatar
    Rustix666 is offline Newbie
    Join Date
    Dec 2009
    Posts
    15
    Rep Power
    0

    Re: More efficient way of writing this Code:

    const
    Letters : ABCDEFGHIJKLMNOPQRSTUVWXYZ;
    var
    i: Byte;
    s: char;
    begin
    s := 'b';
    i := Pos(UpperCase(s), Nextguessedletter); //Return 2
    end;

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help in writing code!!?
    By arjun2 in forum C and C++
    Replies: 1
    Last Post: 10-16-2011, 12:28 PM
  2. Replies: 0
    Last Post: 01-13-2011, 01:29 PM
  3. Is this efficient?
    By Bull3t09 in forum C# Programming
    Replies: 1
    Last Post: 10-26-2010, 08:14 AM
  4. i need help on writing code
    By dpgrhymer2000 in forum C and C++
    Replies: 0
    Last Post: 11-26-2007, 11:31 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts