[fpc-devel] Now sure why this raises Runtime Error 216
Ozz Nixon
ozznixon at gmail.com
Fri Jan 7 15:24:19 CET 2022
Ok, I'll check it out. Thanks guys, did not realize it was a pointer, too
many years writing scripts instead of code. Thanks!!
On Thu, Jan 6, 2022, 11:51 PM Michael Van Canneyt <michael at freepascal.org>
wrote:
>
>
> On Thu, 6 Jan 2022, Ozz Nixon via fpc-devel wrote:
>
> > Procedure Make_Language_File(
> > Description,MenuPath,TextPath,QuestPath:String;
> > Enabled:Boolean;SecurityLevel:Byte;Flags:Longint);
> > Var
> > FileSize:Longint;
> >
> > Begin
> > Writeln('Language_File empty size is ',SizeOf(L));
> > FileSize:=0;
> > Description:=Description+#0;
> > Inc(FileSize,Length(Description));
> > MenuPath:=MenuPath+#0;
> > Inc(FileSize,Length(MenuPath));
> > TextPath:=TextPath+#0;
> > Inc(FileSize,Length(TextPath));
> > QuestPath:=QuestPath+#0;
> > Inc(FileSize,Length(QuestPath));
> > SetLength(L.Description,Length(Description));
> > SetLength(L.MenuPath,Length(MenuPath));
> > SetLength(L.TextPath,Length(TextPath));
> > SetLength(L.QuestPath,Length(QuestPath));
> > Move(Description[1],L.Description,Length(Description));
>
> This code is wrong. That must be
>
> Move(Description[1],L.Description[0],Length(Description));
>
> > Move(MenuPath[1],L.MenuPath,Length(MenuPath));
>
> Same here.
> Move(MenuPath[1],L.MenuPath[0],Length(MenuPath));
>
> > Move(TextPath[1],L.TextPath,Length(TextPath));
>
> Same here
> Move(TextPath[1],L.TextPath[0],Length(TextPath));
>
> > Move(QuestPath[1],L.QuestPath,Length(QuestPath));
>
> Same here.
> Move(QuestPath[1],L.QuestPath[0],Length(QuestPath));
>
> These fields are dynamic arrays, in essence pointers to a memory block.
>
> Your code writes to the memory area for pointer, not to the memory area
> the pointer points to.
>
> Michael.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20220107/a5099796/attachment.htm>
More information about the fpc-devel
mailing list