Error 96

I get Error 96: Too many variables when I attempt to run my program.  That's not a miss reading it does have a lot, so what i'm wondering is if there is a way around this.  Apparently Pascal allows 64k for global vars, is there a way I can extend this?  

Who is Participating?
scrapdogConnect With a Mentor Commented:
Use memory on the heap.  This is not limited to 64K.  If you have exceeded 64k, you probably have some large arrays.  Declare these arrays dynamically by using pointers.

Here is an example:

  TLargeArray = array[0..65519] of byte;
  PLargeArray = ^TLargeArray;

  a,b :PLargeArray;
  i :word;


  for i := 0 to 65519 do begin
    a^[i] := b^[i];


Use getmem to allocate memory on the heap.  Then access the array as you would normally, except use the ^ to dereference the pointer.  When you are doing with the memory, make sure you use freemem to free the allocate memory.

Note that in the type declaration, there are two types...however no memory is allocated here.  The PLargeArray indicates that this is a pointer to the type TLargeArray, and when the variables are declared, they are declared as pointers.  If you were to declare these of type TLargeArray, you would run out of memory, because these wouldn't be declared on the heap.
hansellAuthor Commented:
Thanks!  That helps a lot.
hansellAuthor Commented:
I can't seem to get a round an "invalid qualifier" (error 121)  Heres the scenario

For J:=1 To 300 Do

In your example, the AllocName[I] would be like A, and another B, but for my purposes, i'm using an array for that...[I] being the number...I've getmem'd using Getmem(AllocName[I],300); and that works fine, but when i try to access seen in the code, it doesn't work...thoughts?

It's probably something stupid, but i've tried to stay away from pointers, and am pretty new at them

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Did you declare AllocName as an array of pointers to an array of bytes/integers/etc.?

I will have to see your declarations to see what you are doing wrong.
hansellAuthor Commented:
HAHA!  Stupid idiotic mistake.  Yeah, the error was in the declarations, i had it pointing to some records.  All fixed now, THANKS!  I probably never would've thought the error would have been there!
Also, make sure you remember that the second parameter in getmem is the size in bytes, NOT necessarily the number of elements.  (i.e. if you have 100 integers, you would need 200 bytes, etc.)

A good way to do it is to use the sizeof function:

getmem(pointer, n*sizeof(type))

where n is the number of array elements you want, and type is the type.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.