FidoNet Echomail Archive
locuser

<<< Previous Index Next >>>

From: Paul Edwards
To: Bob Lawrence
Date: 1997-06-05 23:05:12
Subject: Delphi case

BL> you mentioned the limitations of the Pascal CASE statement
BL> that can't handle strings, but there's an easy way around it... use a
BL> string array like... 

BL> const test: array[0..3] of Pchar = ('From:', 'Newsg',
BL> 'Subje', 'fucke');,    
BL> begin

BL> Readln(f, lne);
BL> for n := 0 to 3 do if StrLComp({at}lne[1], test, 5) = 0 then break;
BL> case n of
BL> 0: ...   ;
BL> 1: ...   ;
BL> 2: ...   ;
BL> else ... ;
BL> end;
BL> end;

Now if I could just remember what the supposed advantage of a case
statement over an if-else sequence was, I'd be set for life.  BFN.  Paul.
@EOT:

---
 * Origin: X (3:711/934.9)