granoff@decwin.enet.dec.com (Mark H. Granoff) (11/30/89)
I have a large application, which is only about half done, and is getting
larger. Since memory is at a premium, I've decided that the only (?)
solution is to use overlays. Fortunately, related functions and
procedures are already separated into various include files. So,
converting these large chunks of code into overlayable units should not
be difficult.
Here's the problem. I decided to check out this overlay business with
a little test program (included after this text, from memory). The
problem is that when I run the .EXE, I get a runtime error 208 (which
means that I haven't init'd the Overlay manager). This doesn't make
sense though because the error occurs at the BEGIN for the main
program, before the program would have had a *chance* to init the
overlay manager! What am I missing? Thanks.
OVRUNIT.PAS
UNIT ovrunit;
{$O+,F+}
INTERFACE
procedure ovrjunk;
IMPLEMENTATION
procdure ovrjunk;
begin
writeln('procedure ovrjunk called.');
end;
BEGIN
END.
I compile this and get a .TPU file, as expected.
OVRTEST.PAS
PROGRAM ovrtest;
{$F+}
USES Overlay,ovrunit;
{$O ovrunit}
BEGIN { <------- Run time error occurs here!? }
OvrInit('ovrtest.ovr');
{ examine OvrResult here as appropriate...}
ovrjunk; { call procedure in overlay }
END.
I compile this and get .EXE and .OVR files, as expected.
When I run OVRTEST, I get Runtime error 208. Could it be that I since
I have only one unit overlayed, the overlay manager is getting confused
or something? I probably missed something obvious... Thanks for your
help, and be kind. :-)
Please respond directly to me, since I don't get to read this group
very often,
at granoff@decwin.dec.com --or-- granoff@vaxwrk.dec.com.
-Markjrwsnsr@nmtsun.nmt.edu (Jonathan R. Watts) (12/01/89)
In article <6458@shlump.nac.dec.com>, granoff@decwin.enet.dec.com (Mark H. Granoff) writes: > [Oops, I accidentally deleted a line] > a little test program (included after this text, from memory). The > problem is that when I run the .EXE, I get a runtime error 208 (which > means that I haven't init'd the Overlay manager). This doesn't make > sense though because the error occurs at the BEGIN for the main > program, before the program would have had a *chance* to init the > overlay manager! What am I missing? Thanks. > > OVRUNIT.PAS > UNIT ovrunit; > {$O+,F+} > INTERFACE > procedure ovrjunk; > IMPLEMENTATION > procdure ovrjunk; > begin > writeln('procedure ovrjunk called.'); > end; > BEGIN ^^^^^ > END. The "BEGIN" is the problem. Since you have a begin, the compiler assumes you have an initialization section, and you can't have an overlaid unit with an initialization section BEFORE the Overlay manager has been initialized! For a complete description of the problem (and the solution), see "Initialization Sections in Overlaid Units" on p.167 in the Reference Guide. Sorry for not mailing the response, but this Sun is running VERY, very, slowly today, and I'm not going to go through the hassle of getting this mailed (I've been waiting minutes at a time for the system to respond while typing this message!). If someone wants to forward this to original poster, feel free. - Jonathan Watts jrwsnsr@jupiter.nmt.sun f o d d e r