У меня есть задание для чтения символов один за другим из одного текстового файла и записи их в другой текстовый файл с использованием сценария. Я до такой степени, что могу читать строки за строкой из текстового файла и писать строку в другую.Чтение символов из текстового файла
Эта версия работает ...
%! PS
/infile (input.txt) (r) file def % open files and save file objects
/outfile (output.txt) (w) file def
/buff 128 string def % your buffer for reading operations
{ % loop
infile buff readstring
{ %ifelse
outfile exch writestring
}
{ %else
outfile exch writestring
infile closefile
outfile closefile
exit % exit the loop
} ifelse
} bind loop
Но когда я пытаюсь читать отдельные символы Я получаю сообщение об ошибке говорящее его typemismatch и я не уверен, как решить.
Вот код:
/infile (input.txt) (r) file def % open files and save file objects
/outfile (output.txt) (w) file def
/buff 1 string def % your buffer for reading operations
{ % loop
infile buff read
{ %ifelse
outfile exch write
}
{ %else
outfile exch write
infile closefile
outfile closefile
exit % exit the loop
} ifelse
} bind loop