[fpc-pascal] EAccessViolation
Christo Crause
christo.crause at gmail.com
Thu Aug 13 22:33:10 CEST 2015
On 13 Aug 2015 10:15 PM, "Chris Moody" <inquiry at greensnakedesign.com> wrote:
>
> Hi all,
>
> I have this procedure in my program:
>
> procedure DisplayNode (var node:astring);
> var c, i:integer;
> begin
> i:=SizeOf(node);
> if (i=0) then begin
> writeln ('node was empty / non existant');
> exit;
> end;
> for c:=0 to i do
> writeln (node[c]); // line 85
> end;
>
> astring is an Array of String
>
> The code compiles fine, however when I run it I get:
>
> An unhandled exception occurred at $0000000000400B3A :
> EAccessViolation : Access violation
> $0000000000400B3A line 85 of Dentist.pas
> $0000000000400C8C line 95 of Dentist.pas
>
> Line 85 is the writeln above, line 95 is where I call this procedure from
the main code.
>
> How do I track down what is going on?
>
> If your familiar with PHP, my purpose of this procedure is to basically
emulate the following code:
> <pre><?php print_r (node); ?></pre>
>
> Thanks in advance,
>
> Chris
SizeOf(node) will return the size of the pointer to node. I suspect you
want to loop over elements in an array so use length(node) to find out the
number of elements in node.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150813/10f87e61/attachment.html>
More information about the fpc-pascal
mailing list