wish lists etc

new topic     » goto parent     » topic index » view thread      » older message » newer message

*** Reply to note of 01/02/97 20:35
re: why do i want a case statement.

as with most things, the CASE statement can be done with the classic
if/else/endif. however, the QBASIC (not C!) version is a little bit
different from what you might have in mind. it takes the form:

  SELECT CASE <expression>
   CASE <test>...
   CASE <test>...
   CASE ELSE...
  END SELECT

where the test is the *right hand side* of the expression. it's just
a shorthand, so you can write:

  SELECT CASE foo
   CASE 1 TO 10 ...
   CASE 11,13,17 ...
   CASE > 20 ...
   CASE ELSE
  END SELECT

but yes, you can get the same results with an if clause. the CASE just
gives a shorthand (lazier) way to write. i find:

   CASE 1 to 10

easier to read than:

   elsif foo >= 1 and foo <= 10 ...

although they amount to the same thing.

-- david cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu