Am new to Pascal but not programming. Naturally, I'm tending
to misinterpret statements in the manuals. The below code
compiles okay but bombs on the COPY statement with an access
violation error. Is the problem my use of ansistrings ?
The OS is Windows XP.
A pointer would be appreciated.
Thanks in advance.
program HELLO4;
Uses sysutils;
VAR REC : ANSISTRING;
VAR FLE1A, FLERES : LONGINT; PART : ANSISTRING;
BEGIN
SETLENGTH(REC, 3100);
FLE1A := FileOpen ('C:\THREEWIN\UPDPAT01.WIN',fmOpenRead);
{Semicolons after BEGIN and END done for consistency.}
IF FLE1A < 0 THEN BEGIN; WRITELN ('Open failed.'); exit; END;
FLERES := FILESEEK(FLE1A, 0, fsFromBeginning);
IF FLERES < 0 THEN BEGIN; WRITELN ('Seek failed.'); exit; END;
FLERES := FILEREAD(FLE1A, REC, SIZEOF(REC));
IF FLERES < 0 THEN BEGIN; WRITELN ('Read failed.'); exit; END;
FILECLOSE (FLE1A);
WRITELN ('Trying copy');
PART := COPY(REC, 200, 80);
WRITELN ('Copy sucess');
WRITELN (PART);
END.