Closed Thread
Results 1 to 7 of 7

Thread: Var for just Letters...

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

    Var for just Letters...

    hi,

    what variable should I use for JUST letters, just the 26 letters of the alphabet. No symbols, no numbers etc. I thought of using char, but that includes symbols. Or is there any other way to make an error come up if a letter is not inputted?

    I dont really want to do:

    If (Letter <> a) and (Letter <> b) and (Letter <> c) .... (Letter <> z) and (Letter <> A) and (Letter <> B) and (Letter <> C) .... (Letter <> Z)

    then writeln ('Error');

    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Var for just Letters...

    Try using regular expressions. Either filter out all a-z characters and see if the length is greater than 0 - or do a match or filter out all but a-z etc depending on what you want.

    Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns

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

    Re: Var for just Letters...

    Virtually all languages (including Pascal descendants) use ASCII or Unicode for storing character information. If you want a subset of those characters, such as the upper/lowercase letters in the English alphabet, you need to create a filter. If you know your encoding, you can often do something like:
    Code:
    if not  (((letter >= 'a') and (letter <='z')) or ((letter >= 'A') and (letter <='Z'))) then
    writeln('Error');
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

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

    Re: Var for just Letters...

    Thanks for that Winged Panther Forgot you can use > and < for letters. Thanks to the other guy too, but I didn't really understand lol.

  6. #5
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Var for just Letters...

    Even if you don't use my method learning regular expressions will GREATLY help your programming knowledge in the future.

    Good luck!

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

    Re: Var for just Letters...

    For the English alphabet use:
    Code:
    Letter:=UpperCase(Letter);   //'a'=>'A'
    if (Ord(Letter)<64) or (Ord(Letter)>90) then
    showmessage('Error.');
    Last edited by Jaan; 12-13-2009 at 12:25 PM. Reason: Please use code tags when you are posting your codes!

  8. #7
    Tiago2 is offline Newbie
    Join Date
    May 2008
    Posts
    5
    Rep Power
    0

    Re: Var for just Letters...

    Try this
    Code:
    Var 
      Letter: Char;
    
      if Not (Letter in ['a'..'z','A'..'Z']) then
        ShowMessage('Error.')
    This should let you filter out any charecters that are not in the alphabet

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Arabic letters do not Connect together
    By muskiter in forum PHP Development
    Replies: 1
    Last Post: 12-23-2010, 04:37 PM
  2. Count of Lowercase Letters
    By skastu01 in forum C and C++
    Replies: 8
    Last Post: 08-04-2010, 06:03 AM
  3. Jumbled letters in C
    By twogreenarrows in forum C and C++
    Replies: 6
    Last Post: 06-24-2010, 10:23 AM
  4. Converting letters into a string
    By WiiFan2012 in forum Visual Basic Programming
    Replies: 1
    Last Post: 06-20-2010, 02:22 PM
  5. counting letters?
    By Whitey in forum PHP Development
    Replies: 3
    Last Post: 06-05-2008, 01:49 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