On 17 Feb 2013 at 11:43, Thomas Schneider wrote:
Instead, try
procedure writeprism(var dianalysis: text; var dataprism: trisquare);
That compiles!
You can use "const dataprism : trisquare" as well - if you will not be changing anything in dataprism.
[...]
(a rare case where the use global variables is advised).
That works in the test program and the original (when I make all calls var. THANKS! The reason is that if I define it in a procedure it goes on the stack but if I define it globally the memory for it is allocated as part of the program? Why would that make a difference?
Local variables (and parameters passed by value) go on the stack, which is typically very small. You can increase it in some unix systems. Everything else (AFAIK) goes on the heap - which, put simply (As far as I understand) is as big as all the memory available to the program (installed RAM + virtual memory on the system).
I get segmentation faults when I run with the numbers too big (trimax=2003001). I'm somewhat puzzled by this since I have 26G free Physical memory ... I calculate that for that size it should only take 32048096 = 32,048,096 = 32M integers. What's happening?
Do this at the beginning of your program: writeln (sizeof (trisquare));
You will see exactly how big the data structure is.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/