Koenraad Lelong wrote:
Hi,
Im trying to access an open array but I get a runtime error. I googled a
bit, and found some suggestions, but for me they don't work.
It's actually a port of some C-library I want to use on a STM32-processor.
This is my test-code :
program LCDtest1;
type
TArray = array of byte;
var
nCols : cardinal;
nRows : cardinal;
nBytes : cardinal;
pFont : ^TArray;
{$include fonts.inc}
begin
// get pointer to the beginning of the selected font table
pFont:=@FONT6x8;
writeln('0');
setlength(pFont^,8); <-- here it crashes
I didn't have the setlength at first, then it crashed at the first
access of the array (ncols:=...).
The include file contains this (only partly shown) :
originally :
const
FONT6x8 : array[0..96] of array[0..7] of byte = (
Assuming that in your current implementation FONT6x8 is a table at an
absolute location in memory... I don't think you can do that, since a
dynamic array (which I think is what you're trying to use) is nowt but a
descriptor block which contains a pointer into the heap. Try something like
type TFONT6x8= array[0..96] of array[0..7] of byte;
PFONT6x8= ^TFONT6x8;
var fontTable: PFONT6x8;
Force your absolute address into fontTable, then dereference to get at
the content.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal