Out of String Space

 BBS: Inland Empire Archive
Date: 04-14-92 (09:33)             Number: 97
From: MATT HART                    Refer#: NONE
  To: JASON GORMLEY                 Recvd: NO  
Subj: Out of String Space            Conf: (2) Quik_Bas
Continued from previous...

        Variables : The variables held in Dgroup are simple strings
        (non fixed length) and simple string arrays, simple
        numeric variables (non arrays), TYPE definitions, CONSTants,
        all descriptors to these variables (address' of simple
        numerics, and address' & lengths of simple strings), pointers
        to arrays, and stuff I think even Microsoft isn't sure about.

        DATA : The stuff in DATA statements is in dgroup.

        STATIC : If an array is DIMmed instead of REDIMmed, it's in
        dgroup.  If you don't use the '$DYNAMIC metacommand, then
        most everything is in dgroup - wasting lots of space.
        STATIC can increase the speed of your program - it makes things
        near instead of far - but it won't be increased by very much.

    The most common problem with Dgroup is bad usage of strings.
    For example, if you have DATA statements that are then loaded
    into a string array, your Dgroup is getting double whammied.
    The DATA itself is in Dgroup, then the descriptors for the
    string array are in Dgroup (4 bytes for each element), and then
    the DATA itself is COPIED into the portion of Dgroup pointed to
    as the string array!  If you had 3 sets of 4K of data, that would
    result in about 9K of Dgroup usage - or about 14% !  Put those DATA
    statements out in a disk file and load them.  Compiling your
    program with /S will put quoted strings into the code segment and
    out of dgroup.  PRINT "This is a quoted string".  Most string
    arrays can be converted to far strings.  See the next section for
    an explanation on that.  Use '$DYNAMIC in your programs.  This will
    insure that REDIMmed arrays are placed into far memory.

Third, Far Heap :
    This is the most underutilized, least understand, and BIGGEST
    available memory area.  When a QB program starts, it takes all
    available DOS memory and seperates it into it's CODE segment,
    a 64K Dgroup chunk, and everything that's left is the far heap.
    Fixed length string arrays
        REDIM Strg(1 TO 100) AS STRING * 32
    TYPE arrays
        REDIM EmRec(1 TO 1) AS EmployeeType
    and numeric arrays
        REDIM Amounts(1 TO 100) AS DOUBLE
    go into the far heap.

Continued...

---
 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
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