Running out of variable s

 BBS: Inland Empire Archive
Date: 06-06-92 (16:08)             Number: 108
From: MATT PRITCHARD @ 930/21      Refer#: NONE
  To: ERIC KJELLMAN                 Recvd: NO  
Subj: Running out of variable s      Conf: (2) Quik_Bas
EK>Hi there all.

EK>        I'm looking for a way to increase the number of variables I
EK>can use in a programs... I keep running out of variable space... (I use
EK>an incredible amount of variables... ya know?) I know about the
EK>CLEAR statement, but is there anything else? Cause otherwise
EK>I'm stuck at around 20000 single precision variables... (which
EK>isn't enough for the program I'm writing, unfortunately... I
EK>need about 50000)

EK>see ya around.

What in the world needs about 50000 variables?  Designing a
world class racing ship hull?   Seriously, I assume you are
putting most things in arrays.  In this case, you need to
make your arrays take up "far heap". Look up "$DYNAMIC"
metacommand and REDIM in your docs.  What it does is tell
the compiler that all arrays that follow will be allocated
from the far heap.

Simple variable and arrays are normally allocated from DGROUP which is a
special segement that is only 64K in size.  Each single
percision element take up 4 bytes.  That means only 16384
of them can fit in a segment at absolute most.  To make an
array that holds more than 16K of the them, you need to
investigae the "/AH" switch which allows arrays larger than
64K.

Another limitation, is that an array subscript has a
maximum limit of 32K.   I.e.  REDIM DataVals!(30000) will
make an array of 30000 elements, while REDIM
DataVals!(40000) wont work beacuse of the 32K limit.  Now,
you can get around it using a 2 dimensional Array.. i.e.
REDIM DataVals! (40, 1000), creates a single percision
array with 40 rows of 1000 columns each i.e. 40000
elements.  You can also use TYPEs (Structures) to help you
out.

Hope this gives you some ideas on where to get started.

-Matt Pritchard

===
 * SLMR 2.1a * Backup not found: (A)bort (R)etry (P)anic

--- InterPCB 1.50
 # Origin: CENTRAL BBS -Texas' BEST BBS! 214-393-7090 HST  3+GIGs (8:930/21)
 * Origin: Gateway System to/from RBBS-NET (RBBS-PC 1:10/8)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET