Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!rice!hsdndev!bbn.com!nic!mars!maine!io92203 From: IO92203@MAINE.BITNET (Scott Maxell) Newsgroups: comp.lang.pascal Subject: Re: Help me (problems with strings) Message-ID: <91108.100010IO92203@MAINE.BITNET> Date: 18 Apr 91 14:00:10 GMT References: <1991Apr18.020517.7767@javelin.sim.es.com> Organization: University of Maine System Lines: 28 Tim writes: >I'm getting the error "Type mismatch" in the following: > >Procedure writ(txt:string); > var huh:char; > begin; > for x:=1 to length(txt) do begin > huh:=copy(txt,x,1); <---error occurs here > case huh of > '[' : red; > ']' : rx; > else write(huh); > end; writeln; end; > end; Your type mismatch error is occuring because you are trying to assign a STRING result (from copy) to a CHARACTER variable. You can reference portions of a string directly as characters by using Txt [x]. Your ordinal type expected error was from ORD trying to get the ORDinal of a STRING result again. //////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ +---------+ Scott Maxell -- Bitnet ->> IO92203 @ maine | | -- Internet ->> IO92203 @ maine.maine.edu | O | | | | "What I need is a computer that will do what I want it to +---------+ do, not what I tell it to do..."