Xref: utzoo alt.religion.computers:2538 comp.windows.ms.programmer:3234 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!ukc!slxsys!ibmpcug!mantis!mathew From: mathew@mantis.co.uk (Giving C News a *HUG*) Newsgroups: alt.religion.computers,comp.windows.ms.programmer Subject: Re: ap, Windows BASIC Message-ID: Date: 21 Jun 91 11:54:41 GMT References: <91171.094549F0O@psuvm.psu.edu> Organization: Mantis Consultants, Cambridge. UK. Lines: 86 F0O@psuvm.psu.edu writes: > In article <4k4q47w164w@mantis.co.uk>, mathew@mantis.co.uk (Giving C News a > *HUG*) says: > >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 That's just IF AStringVariable = "everything" OR AStringVariable = AnotherString OR (AStringVariable > "nuts" AND AStringVariable < "soup") ... ELSE ... ENDIF In other words, the SELECT CASE you mention is just syntactic sugar for IF...ELSE...ENDIF. If you happen to prefer the CASE syntax, in C++ you could write yourself a quick macro. And if you want to do lots of comparisons like the one you mention, you could write yourself a quick macro in C++, or a function in Modula-2 or Pascal. > 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 IF ANumericVariable IN { 1,2,3,4, 7,8,9, 11, 13 } OR ANumericVariable > MaxNumber ... ELSE ... ENDIF Pascal and Modula-2 both have suitable set operations to do this. It'll be a bit more work in C++, but not much. In Lisp, both examples are pretty trivial (cond ...) expressions. > >> It is a fully structured language except for the > >> fact you can't have nested blocks as in Pascal. > >That's like saying it's fully object-oriented except it doesn't have > >inheritance... > > Could be, except I don't use nested blocks very often, so I don't miss > it too much. Precisely! Because you don't have the feature, you've never used it. So you don't know how useful and important it is. And then when you move up to a better language, you're trapped in the BASIC mindset. > >> I like about the QB environment is when you press the F2 key, a window > >> pops up with a list of all your procedures/functions. Click on the one > >> you want to look at and bingo. Very nice. > >My editor does that, for C, C++, Pascal, Modula-2, Clipper, or any other > >language you care to tell it about. > > Which editor is that, and how hard was it to set up? Brief. I put the disk in and typed "SETUP", and told it which languages I would be using. Selected from a menu. Oh, and I wrote a couple of pages of code to re-bind the editor keys to what I'm used to. I take it I could do the same with QuickBASIC? mathew