Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!sharkey!tygra!dave From: dave@tygra.UUCP (David Conrad) Newsgroups: comp.lang.pascal Subject: Re: TP3.01 Changing Case (U or L) help Message-ID: <1991Feb18.100419.10828@tygra.UUCP> Date: 18 Feb 91 10:04:19 GMT References: <37727@netnews.upenn.edu> Distribution: usa Organization: Moore Software, Detroit, MI Lines: 58 In article <37727@netnews.upenn.edu> garay@hyper.lap.upenn.edu (John Garay) writes: > >I am trying take a string of mixed Upper and Lower Case characters and >convert them ALL into lower case. > >So, you see my quandry. The TP5.5 procedure "UpCase" is not available >w/ TP3.01... > >So, specifically, how do I check case? and How do I then convert case? program test; type strng = string[255]; function LowCase (ch : char) : char; begin if (ch >= 'A') and (ch <= 'Z') then LowCase := chr(ord(ch) + (ord('a') - ord('A'))) else LowCase := ch; end; function LowString (s : strng) : strng; var i : integer; begin for i := 1 to length(s) do s[i] := LowCase(s[i]); LowString := s; end; begin writeln (LowString('This String was in Mixed Case!')); end. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- The above program should answer your questions. It compiled and ran in both Turbo Pascals 3.02A and 5.5, although in 5.5 `strng' would not be necessary as string could be used. Also, Var-string checking should be set to relaxed {$V-} in 5.5, I don't recall if there's an equivalent to this in 3.x. Since someone is bound to comment on my use of ord('a') - ord('A') instead of just 32, let me mention that this program could be ported to JSPASCAL running under MTS on the system/370 mainframe down at Wayne State U where I go to school with almost no trouble (the declaration of strings is slightly different in JSPASCAL, strings not being supported in standard Pascal) even though that system uses EBCDIC rather than ASCII. Try that with your 32 version. If you don't know what EBCDIC is, don't worry - be happy. :-) -- David R. Conrad | "Please excuse me if I don't quite understand, tygra!dave@uunet.uu.net | I'm just a stranger in Electric Land." sharkey!tygra!dave | -- Bad Company, "Electric Land" -- = CAT-TALK Conferencing Network, Computer Conferencing and File Archive = - 1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new' - = as a login id. AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET") = E-MAIL Address: dave@DDMI.COM