Subject: 64k limit ?????? data segment error ....
> >>You can :
> >>1) Split the data into different units.
> >This must me one of the most common false advices in this group. It does
> >not help as the data segment is global.
> Oh really????
> Isn't it possible for an executable to declare more than one data
> segment (or am I talking rubbish).
Insofar as TP/BP is concerned, this is rubbish. 8<}} TP/BP allows
the use of only a single Data Segment, which it constructs from all the
(referenced) Var data declared in all the referenced Units and source of
the program. You are allowed only (that infamous) 64K of such program
data - that which is declared as Var data, that is.
However, some of that Var data can be Pascal pointers, so the actual
"data" used by the program can be allocated (stored) on the Heap - giving
the program capability to "use" much more than 64K bytes of "data". You
must know how to work with Pascal pointers, though.
Also, procedure-local data (Vars declared inside subprograms) can be
as much as has been reserved for the Stack - also a 64K total limit
there. It's thus possible to use almost 128K of Var data, given the
structure of the program and how much local data is declared in higher
Finally, there's the concept called Smart Linking, where only
_referenced_ Var data is actually linked into the programs (which becomes
part of that 64K limit), and it's often likely that all the Var date
declared in a Unit isn't truly referenced by the program Using the Unit.
A feature in TP/BP known as "Var blocks" (declaring data in multiple
Vars), "grouped" according to the programs which Use the Unit) allows the
Smart Linker to see only pertinent data when doing the link. This
valuable technique isn't simple or easy to use, since one must know a lot
about how global Unit data is used and by what other programs and Units.
> I don't know of any technical reason why the app can't declare more
> than one data segment..... enlighten me.
There may not be any _technical_ reason, but that's how Borland
implemented the data aspect of their Pascal systems. I believe it's so
the optimize data referencing by loading once and maintaining the
contents of a hardware register throughout the duration of the program's
> I would think no more than 64k of data per unit, yes, but I'm sure
> I've made DOS apps with more than 64k overall.
Yes, but not with TP or BP, I'm sure...8<}}