Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!romp!auschs!awdprime!ziggy.austin.ibm.com!ehill From: ehill@ziggy.austin.ibm.com Newsgroups: comp.lang.pascal Subject: Re: Help me (problems with strings) Message-ID: <6792@awdprime.UUCP> Date: 18 Apr 91 14:42:20 GMT References: <1991Apr18.020517.7767@javelin.sim.es.com> Sender: news@awdprime.UUCP Organization: IBM AWD, Austin Lines: 30 In article <1991Apr18.020517.7767@javelin.sim.es.com> tpehrson@javelin.sim.es.com 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; --- The type mismatch happens because the copy() function returns a string not char. Replace the line where you assign the value to huh with the following: huh := txt[x]; This works because strings can be subscripted the same as normal arrays. This should also clear up the ordinal value problems as well. In Pascal characters, numerics, and enumerated types are considered ordinal variable types. Hope this helps, --- Ed Hill Personal Systems Programming, IBM Austin internet: ehill@wombat.austin.ibm.com