(* If FPC version 3.2.0 or later is used, it is able to validate that error *)
(* messages correctly identify what function was being executed at the time: *)
(* this is important since it includes parsing rules where an error indicates *)
(* either something wrong in the input file or a flaw in the program. Versions *)
(* of FPC predating 2.2.4 lack the FPC_FULLVERSION predefined, so cannot fail *)
(* gracefully when they try to determine whether the CURRENTROUTINE expansion *)
(* is available. Other factors mandate that in practice FPC older than 2.6.0 *)
(* will be unable to compile this source file without significant modification. *)
{$undef HAS_CURRENTROUTINE }
{$if FPC_FULLVERSION >= 030200 } (* Requires FPC 2.2.4 minimum *)
{$define HAS_CURRENTROUTINE } (* Requires FPC 3.2.0 minimum *)
{$assertions on } (* Make sure name checks are operative *)
{$endif FPC_FULLVERSION }
...
(* Parse the PEC thumbnail section.
*)
function pec_thumbnailImageSubsection(): boolean;
const
thisName= 'pec_thumbnailImageSubsection()';
var
backtrack: int64;
i: integer;
begin
{$ifdef HAS_CURRENTROUTINE }
Assert(thisName = {$I %CURRENTROUTINE%} + '()', 'Internal error: bad name in ' +
{$I %CURRENTROUTINE%} + '()');
{$endif HAS_CURRENTROUTINE }
result := false;
pushRule(thisName);
backtrack := FilePos(pesIn);
header;
if FilePos(pesIn) <> pecThumbnailByteOffset then begin
WriteLn('*** In ', peekRule(), ': thumbnail image isn''t contiguous with stitchlist');
WriteLn(Up + 'Backtrack ', popRule());
Seek(pesIn, backtrack);
exit
end;
for i := 0 to thumbnailColours do begin
WriteLn('Thumbnail colour: ', i);
ReadU8G(pesIn, pesOut, thumbnailWidth, thumbnailHeight, i)
end;
WriteLn(Up + 'OK ', popRule());
result := true
end { pec_thumbnailImageSubsection } ;