Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!umich!terminator!um.cc.umich.edu!userW6BP From: userW6BP@um.cc.umich.edu Newsgroups: comp.lang.pascal Subject: Re: What's wrong with this: Message-ID: Date: 20 Apr 91 05:38:05 GMT References: <1991Apr20.011454.25016@javelin.sim.es.com> Sender: usenet@terminator.cc.umich.edu (usenet news) Organization: University Of Michigan, Ann Arbor Lines: 32 In article <1991Apr20.011454.25016@javelin.sim.es.com>, tpehrson@javelin.sim.es.com writes: >why doesn't this work: > >function upper(I:string):string; > var z:integer; > begin > for z:=1 to length(I) do > if (ord(I[z])>96) and (ord(I[z])<123) then I[z]:=upcase(I[z]); > end; > >i have a feeling i'm overlooking the obvious ... Yes, you are. You need to set the function to the value of the altered string: FUNCTION upper(I:string):string; VAR z : INTEGER; BEGIN FOR z := 1 TO LENGTH(I) DO IF (ORD(I[z]) > 96) AND (ORD[I[z]) < 123) THEN I[z] := UPCASE(I[z]); upper := I; (* This is what you were missing *) END; --Allan