{ Back to strings as forward lists. One thing you would like to be able to do is copy strings. I have written a procedure Copy below, but it's bad. What's wrong with it? Not sure why my Copy is bad? Try this in the main program. ReadString( message1 ); Copy( message1, message2 ); Decapitalize( message2 ); write( 'Original: ' ); WriteString( message1 ); writeln; write( 'Decapitalized version: ' ); WriteString( message2 ); writeln; What happened, and why? Now, write a better Copy. } program copying(input,output); type nodePtr = ^node; node = record data : char; next : nodePtr end; var message1, message2 : nodePtr; { ReadString reads characters from the keyboard until reaching the end of a line. The characters are put into a linked list, with str pointing to the head of the list (which is also the first character read). } procedure ReadString( var str : nodePtr ); var currentNode : nodePtr; begin if eoln then str := nil else begin new( currentNode ); read( currentNode^.data ); str := currentNode; while not eoln do begin new( currentNode^.next ); currentNode := currentNode^.next; read( currentNode^.data ) end; currentNode^.next := nil end end; { WriteString prints a string stored as a linked list of characters. } procedure WriteString( str : nodePtr ); var currentNode : nodePtr; begin currentNode := str; while currentNode <> nil do begin write( currentNode^.data ); currentNode := currentNode^.next end end; { Changes all the upper-case letters in the list pointed to by str to lower-case. } procedure Decapitalize( str : nodePtr ); var currentNode : nodePtr; c : char; begin currentNode := str; while currentNode <> nil do begin c := currentNode^.data; if (c >= 'A') and (c <= 'Z') then currentNode^.data := chr( ord(c) - ord('A') + ord('a') ); currentNode := currentNode^.next end end; procedure Copy( str1 : nodePtr; var str2 : nodePtr ); begin str2 := str1 end; begin end.