Solved

Error 96

Posted on 1998-12-01
6
743 Views
Last Modified: 2010-04-16
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?  

Thanks
0
Comment
Question by:hansell
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
scrapdog earned 70 total points
ID: 1216262
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:


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

var
  a,b :PLargeArray;
  i :word;

begin
  getmem(a,65520);
  getmem(b,65520);

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

  freemem(a,65520);
  freemem(b,65520);
end.


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.
0
 

Author Comment

by:hansell
ID: 1216263
Thanks!  That helps a lot.
0
 

Author Comment

by:hansell
ID: 1216264
I can't seem to get a round an "invalid qualifier" (error 121)  Heres the scenario

For J:=1 To 300 Do
Begin
  ...bla...
  AllocName[I]^[J]:=Data;
  ...bla...
End;

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 it...as 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


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:scrapdog
ID: 1216265
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.
0
 

Author Comment

by:hansell
ID: 1216266
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!
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1216267
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tstream to hex 1 1,670
delphi 8 620
Delphi: Read a array of strings in a OleVariant 4 1,081
proper way to parse text with delphi 7 101
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
A simple overview of the possibilities of using technology for project management.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now