There was a very strange error invalid pointer operation, the frequency of its occurrence is even stranger. There is a code:
for i := 0 to (fpos div length(longke)) do longkey := longkey + longke; for i:= 0 to fpos do AByte[i]:= AByte[i] xor ord(longkey[i+1]); noticed that if you remove the cycle
for i := 0 to (fpos div length(longke)) do longkey := longkey + longke; then there is no error, just by typing, I realized that if I noted a line
AByte[i]:= AByte[i] xor ord(longkey[i+1]); then there is no error either, so it’s obviously a deal with her. The very same error occurs at the end of the program and shows
Application.CreateForm(TForm1, Form1); Application.Run; end. // сюда sometimes the error goes away itself, I didn’t touch anything, I didn’t change the code, and suddenly the error stopped appearing, but then it started again, what kind of magic?
Addition # 1: I realized that if we declare an array static, there is no error, here’s the code:
var f: file of byte; AByte: array of byte; bytee : byte; i,k,fpos,sc,vv,pol :integer; CodeText : longint; longke,longkey: AnsiString; begin longke:='c28a50a73a5ccc2373c1015e41022df4'; AssignFile(f, 'C:\45.docx'); Filemode := 2; Reset(f); k := FileSize(f); fpos:=200; SetLength(AByte, fpos); for i := 0 to (fpos div length(longke)) do longkey := longkey + longke; seek(f,0); BlockRead(f, AByte[0], fpos); for i:= 0 to fpos do AByte[i]:= AByte[i] xor ord(longkey[i+1]); seek(f,0); BlockWrite(f, AByte[0], fpos); end;