Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!spruce.cis.ohio-state.edu!thurn From: thurn@spruce.cis.ohio-state.edu (Martin Thurn) Newsgroups: comp.lang.pascal Subject: Re: Converting Strings to Char Message-ID: <35934@tut.cis.ohio-state.edu> Date: 18 Feb 89 17:17:37 GMT Sender: news@tut.cis.ohio-state.edu Reply-To: Martin Thurn Organization: Ohio State University Computer and Information Science Lines: 49 In article <1701@westfort.UUCP> westfort!dragon@tut.cis.ohio-state.edu writes: >procedure send(ch:char); > >begin...end; > >var > x:integer; > s:string[80]; > sd:string[1]; > >begin > s:='Hello'; > for x:=1 to length(s) do begin > sd:=copy(s,x,1); > send(sd); (* The problem.. Can't send a string through as a char.. *) > end; > end; >... In TP 5.0, char just "ain't nohow" compatible with string (a minor change from earlier versions, I believe). If procedure send() expects a char, you have to give it a char and nothing but a char: var x: integer; s: string[80]; c: char; begin s := 'Hello'; for x := 1 to length(s) do begin c := s[x]; (* string indexed with [] returns char at that position *) send(c); end; end; ---Martin Thurn thurn@cis.ohio-state.edu ______________________________________________________________________________ "Heaven is an American salary, | Hell is a Chinese salary, a Chinese cook, | an English cook, an English house, and | a Japanese house, and a Japanese wife. | an American wife." - James Kabbler -=- ---Martin Thurn thurn@cis.ohio-state.edu ______________________________________________________________________________ "Heaven is an American salary, | Hell is a Chinese salary,