Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!munnari.oz.au!uniwa!cc.curtin.edu.au!sdalelt From: sdalelt@cc.curtin.edu.au Newsgroups: comp.lang.pascal Subject: Re: Cool strings unit Message-ID: <1991Apr20.130922.7855@cc.curtin.edu.au> Date: 20 Apr 91 05:09:22 GMT Article-I.D.: cc.1991Apr20.130922.7855 References: <1991Apr17.084358.2932@usenet.ins.cwru.edu> Organization: Curtin University of Technology Lines: 64 In a msg dated [Wed Apr 17 1991], William C. Thompson wrote: > WCT: Here's a cool unit to do stuff with strings... > WCT: unit strings; > WCT: interface > WCT: [..] You may want to add the following to your strings unit. Since it uses some non-standard stuff, it only works with Turbo Pascal. {---------------------------------------------------------------------------} function pretty(s : string) : string; {-prettify a string to correct case } var count : byte; sl : byte absolute s; flag : boolean; {-------------------------------------------------------------------------} function lowcase(c : char) : char; var b : byte absolute c; begin c := upcase(c); if c in ['A'..'Z'] then b := b + 32; lowcase := c; end; {-------------------------------------------------------------------------} begin flag := false; for count := 1 to sl do if upcase(s[count]) in ['A'..'Z'] then if flag then s[count] := lowcase(s[count]) else begin flag := true; s[count] := upcase(s[count]); end else flag := false; pretty := s; end; {---------------------------------------------------------------------------} Cheers, Lincoln. _____________________________________________________________________________ Internet: sdalelt@cc.curtin.edu.au Voice: +61-9-459-4701 lincoln_dale@f627.n690.z3.fidonet.org FidoNet: Lincoln Dale @ 3:690/627.0 Data: +61-9-493-1534 PSImail: psi%050529452300070::sdalelt +61-9-493-2625 UUCP: uunet!munnari.oz!cc.curtin.edu.au!sdalelt Bitnet: sdalelt%cc.curtin.edu.au@cunyvm.bitnet