Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!ogicse!pdxgate!eecs!mwizard From: mwizard@eecs.cs.pdx.edu (Craig Nelson) Newsgroups: comp.lang.pascal Subject: Re: TP3.01 Changing Case (U or L) help Message-ID: <1653@pdxgate.UUCP> Date: 17 Feb 91 10:09:48 GMT References: <37727@netnews.upenn.edu> Sender: news@pdxgate.UUCP Distribution: usa Lines: 44 garay@hyper.lap.upenn.edu (John Garay) writes: >Hi, I'm in need in some help with Turbo Pascal 3.01 and would appreciate >assistance. >Okay, here goes: >I am trying take a string of mixed Upper and Lower Case characters and >convert them ALL into lower case. I would use a form such as: > If UppercaseChar then MakeLowercase; >I just don't know how to check the chars of a string for case and even if I >did, I don't know how to convert the Upper Case chars down to 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? >Any help would be much appreciated. Thanks... Problem is simple in TP4.0 or later, but for you a little tricky. Since I did not use TP3.* for the longest time I can't remember of you are allowed to typecast characters as bytes. I can only assume no. What you need to do is take the Ord() value of the characte, and manipulate it in such a fashion. See below: Procedure LowCase(Var Ch:Char); Var i:Integer; Begin if (Ord(Ch)>=65 and Ord(Ch)<=90) then Ch:= Char(Ord(Ch)+32); End; Call this on the entire array (string) whatever. It will not touch the non-uppercase characters, and will convert all uppercase to lower case. For i:= 1 to StrLen do LowCase(MyString[i]); Don't you love pascal ? By the way, that function above will also work in standard pascal, and is not limited to just the Turbo family. Craig (mwizard@eecs.ee.pdx.edu)