Tell me please. I hung on some strange situation. The program for encoding and decoding wrote. It works - everything is ok. The text is encoded, but with the decoding of something extremely strange and I can not understand how this is possible.
Firstly: the file is decoded completely except for the last 3.5 lines. How so? Secondly: all the files that I launch are encoded, but not all are decoded, only selectively - something is yes, something is not. If the file is not decoded, the program creates it but leaves it blank. Why?
I also take into account the fact that I encode and decode the same file. In the sense that at first bora is ready - I encode it in a new - empty, I decode it in the third - a new empty. Then I compare the values and - on you!
const Ckey=3; function shifr(i:char):char; begin ord(I):=ord(i)+Ckey; if ord(i)>255 then ord(i):=ord(i)-255+32; shifr:=i; end; function deshifr(i:char):char; begin ord(I):=ord(I)-Ckey; if ord(i)<32 then ord(i):=ord(i)+255-32; deshifr:=i; end; procedure strshifr(var a1,b1:text); var x:integer; s:string; begin reset(a1); rewrite(b1); while (not EOF(a1)) do begin readln(a1,s); for x:=1 to length(s) do s[x]:=shifr(s[x]); writeln(b1,s); end; close(b1); end; procedure strdeshifr(var b2,c2:text); var x:integer; s:string; begin reset(b2); rewrite(c2); while (not EOF(b2)) do begin readln(b2,s); For x:=1 to length(s) do s[x]:=deshifr(s[x]); writeln(c2,s); end; end; var a,b,c:text; x:integer; q:string; begin assign(a,'P_24_1.pas'); assign(b,'P_26_3.pas'); assign(c,'P_26_4.pas'); writeln('Введите номер действия:1-шифровать, 2-дешифровать'); readln(x); case x of 1:q:='Программа шифрования запущена'; 2:q:='Программа дешифрования запущена' else q:='неверный номер действия'; end; writeln(q); if x=1 then strshifr(a,b); if x=2 then strdeshifr(b,c); close(a); close(b); close(c); readln; end.