BBS: Inland Empire Archive Date: 11-12-92 (13:31) Number: 341 From: TONY ELLIOTT Refer#: NONE To: JON LEGER Recvd: NO Subj: Re: HELP! Conf: (2) Quik_Bas
Jon, JL> Could someone explain to me what $DYNAMIC means? And while you're at JL> it, STATIC... What does all that do? QuickBASIC has two different areas in which your variables are stored: DGroup (sometimes called the "near heap") and the "far heap". Data stored in DGroup are your non-array variables ("scalars"), and static arrays. Data stored in DGroup can be accessed the quickest. The problem is Dgroup is limited to a total of 64K. "static" arrays are those which are allocated at compile-time to a fixed size (they can't be erased or REDIMed) and stored in DGroup. Because BASIC uses DGroup for lots of other things as well (internal variables, the stack, etc.), you can quickly run out of DGroup space after allocating one or two big arrays. The $STATIC metacommand tells BASIC to place all arrays (except for variable-length string arrays) allocated after the statement in DGroup. "Dynamic" arrays are allocated at runtime and placed in the far heap. The far heap consists of all conventional DOS memory except for your code space and that which DGroup occupies. The $Dynamic metacommand directs BASIC to place all arrays (again, except for variable-length string arrays) on the far heap. Dynamic arrays can be erased (removed from memory) and REDIMed to a different size. However, access to dynamic arrays is slows than static arrays. Most feel this is a reasonable trade-off. Like with any rule, there are exceptions. While in the QB/QBX/VBDOS environments, all arrays are dynamic - regardless of the use of $STATIC/$DYNAMIC (there's even an exception to this rule, which I won't bother going into right now). Also, regardless of being in the IDE or in an .EXE, arrays DIMed in a dynamic procedures are dynamic by nature. Also, using REDIM or a variable to define the array bounds (e.g. DIM Array$(1 TO Top%)) will make the array dynamic. Thoroughly confused? Tony ... I know a good tagline when I steal one. --- Blue Wave/Max v2.10 [NR] * Origin: Oakland BBS - McDonough, GA - (404) 954-0071 (1:133/706.0)
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