Xref: utzoo alt.religion.computers:2536 comp.windows.ms.programmer:3229 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!cernvax!chx400!bernina!bernina!neeri From: neeri@iis.ethz.ch (Matthias Ulrich Neeracher) Newsgroups: alt.religion.computers,comp.windows.ms.programmer Subject: Re: ap, Windows BASIC Message-ID: Date: 21 Jun 91 12:35:52 GMT References: <91169.084617F0O@psuvm.psu.edu> <4k4q47w164w@mantis.co.uk> <91171.094549F0O@psuvm.psu.edu> Sender: news@bernina.ethz.ch (USENET News System) Followup-To: alt.religion.computers Organization: Integrated Systems Laboratory, ETH, Zurich Lines: 77 In-Reply-To: F0O@psuvm.psu.edu's message of 20 Jun 91 13:45:49 GMT Nntp-Posting-Host: etzj-gw In article <91171.094549F0O@psuvm.psu.edu> F0O@psuvm.psu.edu writes: [I set the followup to alt.religion.computers, as I don't read the most esteemed forum comp.windows.ms.programmer] >In article <4k4q47w164w@mantis.co.uk>, mathew@mantis.co.uk (Giving C News a >*HUG*) says: >>F0O@psuvm.psu.edu writes: >>> It has some nice features I wish were >>> in Pascal or other languages. Like QB's SELECT CASE statement; much more >>> powerful then Pascals. >>What, you mean it allows general boolean expressions for each CASE, like >>Clipper 5.0 does? That makes it just syntactic sugar; most other languages >>have the same feature available, they just call it IF...ELSEIF...ENDIF. > > Two examples should get my point across: > > This segment will match strings that are exactly equal to "everything" >the current value of AnotherString, or that fall between "nuts" and "soup" >in alphabetical order > > SELECT CASE AStringVariable > CASE "everything", "nuts" TO "soup", AnotherString > ... > END SELECT > > This code will compare ANumericVariable for numbers between 1 and 4, >7 to 9, 11, 13, or if ANumericVariable > MaxNumber > > SELECT CASE ANumericVariable > CASE 1 to 4, 7 to 9, 11, 13, IS > MaxNumber > ... > CASE ELSE > ... > END SELECT OK. Now, let's assume that we have defined a string class in C++ (The nice thing about C++ is that you can do this. In BASIC, you can't): String AStringVariable; String AnotherString; ... if (AStringVariable == "everything" || (AStringVariable >= "nuts" && AStringVariable <= "soup) || AStringVariable == AnotherString ) { ... } if ((ANumericVariable >= 1 && ANumericVariable <= 4) || (ANumericVariable >= 7 && ANumericVariable <= 9) || ANumericVariable == 11 || ANumericVariable == 13 || ANumericVariable > MaxNumber } { ... } Why do I like the C++ version more than the BASIC one ? - The C++ version works for all data types, the BASIC one only for numbers and Strings - The meaning of the C++ version is more obvious (Once you have figured out what "&&" and "||" mean and why it's "==", not "=" :-). I had very big problems figuring out the meaning of your first example without reading your explanation. - While the BASIC version clearly shows the comfortable string handling built into BASIC, it also points at the difficulties you're going to have as soon as you need something that is *not* built in. How would the above string example look if you wanted to compare the strings according to German string ordering rules and not according to ASCII ? - BASIC has introduced an obscure, ugly, and non-portable syntax to handle some infrequent cases (Do you have an actual example where this generality is needed ?). Matthias ----- Matthias Neeracher neeri@iis.ethz.ch "These days, though, you have to be pretty technical before you can even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_