Newsgroups: comp.lang.pascal Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!linus!agate!usenet.ins.cwru.edu!po.CWRU.Edu!wct From: wct@po.CWRU.Edu (William C. Thompson) Subject: Cool strings unit Message-ID: <1991Apr17.084358.2932@usenet.ins.cwru.edu> Sender: news@usenet.ins.cwru.edu Nntp-Posting-Host: cwns6.ins.cwru.edu Reply-To: wct@po.CWRU.Edu (William C. Thompson) Organization: Case Western Reserve University, Cleveland, OH (USA) Date: Wed, 17 Apr 91 08:43:58 GMT Lines: 72 Here's a cool unit to do stuff with strings... unit strings; interface function allup(s:string):string; { changes all letters in a string to uppercase } function lowcase(c:char):char; { un-captializes a letter } function alllow(s:string):string; { un-capitalizes a string } function rep(s:string; n:integer):string; { makes n copies of s } procedure reverse(var s:string); { reverses s } implementation function allup(s:string):string; var i:byte; begin for i:=1 to length(s) do s[i]:=upcase(s[i]); allup:=s end; function lowcase(c:char):char; begin if c in ['A'..'Z'] then c:=chr(ord(c)+32); lowcase:=c end; function alllow(s:string):string; var i:byte; begin for i:=1 to length(s) do s[i]:=lowcase(s[i]); alllow:=s end; function rep(s:string; n:integer):string; var t: string; i: integer; begin t:=''; for i:=1 to n do t:=t+s; rep:=t end; procedure reverse(var s:string); var t: string; l,i: integer; begin l:=length(s); t:=s; for i:=l downto 1 do t[l+1-i]:=s[i]; s:=t end; end. -- Ticking away, the moments that make up a dull day. | William C. Thompson You fritter and waste the hours in an offhand way. | Michelson 620D (wct) Kicking around on a piece of ground in your hometown,| a.k.a. Master of Time, waiting for someone or something to show you the way.| Space, and Dimension