Article View: borland.public.jbuilder.java.language
Article #8108Re: Simple CASE Statement
From: Dave Bird
Date: Wed, 18 Apr 2001 20:37
Date: Wed, 18 Apr 2001 20:37
45 lines
2517 bytes
2517 bytes
In article <tVkD6.2213$a46.163906@news2-win.server.ntlworld.com>,
rwinslow <rwinslow@hotmail.com> writes
>What I want to do in another part is to check that the char at a place in a
>String is either a number, a lower case letter or a capitol letter. I think
>it is along the lines of 'case "a..z" ' but have been unable to compile
>using single/double quotes in several combinations like 'a' .. 'z' and all
>the others I can think of.
As best i know -- correct me if I am out of date -- neither Java
not C++ allows you to "case" a RANGE of constants.
I don't know which language does do that..... Pascal, maybe?
The way you can get round it is have a function which changes these
ranges into a single number then "case" on that:
class MyClass{
//---
static final int AtoZ = 128,
atoz = 129;
//---
void doSomething(c1){
switch(mapChar(c1)){
case '0': .......
case '1': .......
case '2': .......
case AtoZ: ......
case atoz: ......
};
};
//----
char macChar(char c1){
;;;; if('A'<=c1 && c1<='Z') then return AtoZ;
else if('a'<=c1 && c1<='z') then return atoz;
else if('0'<=c1 && c1<='9') then return c1;
else if(c1 > 128 ) then return 0;
else return c1;
};
};
--
^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/
(..)__u news:alt.smoking.mooses
Technical Details
Message-ID:
<y7xu7hP5rf36Ew8s@xemu.demon.co.uk>Path:
arc1-ca.pugleaf.net!supernews.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!daveReferences:
<tVkD6.2213$a46.163906@news2-win.server.ntlworld.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,b321939a52036c70 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-04-18 13:46:02 PST Path: arc1-ca.pugleaf.net!supernews.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!dave From: Dave Bird <dave@xemu.demon.co.uk> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Simple CASE Statement Date: Wed, 18 Apr 2001 21:37:13 +0100 Organization: none Message-ID: <y7xu7hP5rf36Ew8s@xemu.demon.co.uk> References: <tVkD6.2213$a46.163906@news2-win.server.ntlworld.com> NNTP-Posting-Host: xemu.demon.co.uk X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209 X-Trace: news.demon.co.uk 987626345 nnrp-09:28097 NO-IDENT xemu.demon.co.uk:158.152.196.209 X-Complaints-To: abuse@demon.net MIME-Version: 1.0 X-Newsreader: Turnpike Integrated Version 5.00 U <dQumtnY$x4rJ2u5tL5fS$n2vuP> Lines: 45