Array's TOO BIG?? 
Author Message
 Array's TOO BIG??

Hi there,

Thanks for the replies on my earlier question. It helped a lot.
As you can see below.
The "XY Coord DIM" workes fine now.

However!!!!!!! Only with small INDEXES like 30 (=900 char)
Now I want to print a whole sheet of paper with all the characters
in the "XY Coord DIM".  Thats about 9000 characters.

BUT when I made DIM  textlist(80, 80).  (= 6400 char)
instead of textlist(30, 30)  it said "OUT OF RANGE" or
"OUT OF STRINGSPACE"

I tried to make subroutines (See code below) but that didn't help.

I thought.... Quote;"Valid index values range from -32,768 to 32,767."
SO how can I make the array smaller.!
I mean what's the problem there anyway!

:-(

Thanks
Marco

CLS
             ' NOTE: There are ONLY TWO TEXTBLOCKS NR 2, NR 3!!!

'--------------------DATA-----------------------------------------
tekst2$ = "Aufwiedersehen"                                      
'Text two
tekst3$ = "ALOHAAA"                                              
'Text three

DIM SHARED textlist(1 TO 81, 1 TO 81) AS STRING         ' init 2D
array textlist

yy% = 0                                ' y variable in "leegtevullen"
subroutine
yyy% = 0                              ' y variable in "printlist"
subroutine

xtekst2% = 15                        ' starting X coord of text two
ytekst2% = 2                         ' starting Y coord of text two
kolomlengte2% = 6                  ' the width of the text block
(>6...= return)

xtekst3% = 3                          ' starting X coord of text three
ytekst3% = 1                          ' starting Y coord of text three
kolomlengte3% = 5                   ' the width of the text block
(>5...= return)

uu% = 0                               ' variable used in subroutine
"vultext2" for MID$....
udrie% = 0                            ' variable used in subroutine
"vultext3" for MID$....

'---------------------METHODS----------------------------------

FOR k% = 0 TO 6399                 ' Giving all the X,Y coord a "."
character
???GOSUB leegtevullen
NEXT k%

tekst2: 'Locating the X,Y coor of text two +
FOR x2% = 1 TO 80 ' giving the X,Y the right char of text
two
????????GOSUB vultext2 ' see subroutine "vultext2"
NEXT x2%

tekst3: ' Same for text three as text two
FOR xdrie% = 1 TO 80
????????GOSUB vultext3
NEXT xdrie%

FOR i% = 1 TO 6399 'Put all the all the values of textlist
???????GOSUB printlist ' together and print them in a $
variable
NEXT i% ' called "totaaltext$"
PRINT totaaltext$;
END
'----------------------SUBROUTINES-----------------
leegtevullen:
????????yy% = yy%
????????xx% = xx% + 1
????????m = k% MOD 80
????????IF m = 0 THEN
????????xx% = 1
????????yy% = yy% + 1
????????END IF
???????'**************HERE IT SAYS "OUT OF**************
?textlist(yy%, xx%) = "."          '****** STRINGSPACE"*********

RETURN

vultext2:
teller2% = x2% + (kolomlengte2% - 1)
B = teller2% MOD kolomlengte2%
IF B = 0 THEN
xtekst2new% = xtekst2%
ytekst2new% = (ytekst2% + (teller2% / kolomlengte2%)) - 1
ELSE
xtekst2new% = xtekst2new% + 1
ytekst2new% = ytekst2new%
END IF
uu% = (uu% + 1)
textlist(ytekst2new%, xtekst2new%) = MID$(tekst2$, uu%, 1)
RETURN

vultext3:
tellerdrie% = xdrie% + (kolomlengte3% - 1)
bb = tellerdrie% MOD kolomlengte3%
IF bb = 0 THEN
xtekst3new% = xtekst3%
ytekst3new% = (ytekst3% + (tellerdrie% / kolomlengte3%)) - 1
ELSE
xtekst3new% = xtekst3new% + 1
ytekst3new% = ytekst3new%
END IF
udrie% = (udrie% + 1)
textlist(ytekst3new%, xtekst3new%) = MID$(tekst3$, udrie%, 1)
RETURN

printlist:
yyy% = yyy%
xxx% = xxx% + 1
n = i% MOD 80
IF n = 0 THEN
xxx% = 1
yyy% = yyy% + 1
END IF
totaaltext$ = totaaltext$ + textlist(yyy%, xxx%)
RETURN



Thu, 24 Jun 2004 03:33:21 GMT  
 Array's TOO BIG??
The first thing you really need to do is to find out how your version of
Basic allocates it's data space.  QB4.0 and up allow for huge arrays (use
the /h parameter when starting the program) which don't use up the 64K of
the data space as much.  You may be also having a problem as the array
element is going to be bigger than the string size (don't forget that when
figuring the size of the array!) by a few characters which are used to
define the size of the string.

--
Bob May
Imagine the terrorist's fun when they realize that their 72 "nubile {*filter*}s"
are all {*filter*}s and cranky from it being that time of the month!



Thu, 24 Jun 2004 05:34:51 GMT  
 Array's TOO BIG??


[...]

Quote:
> BUT when I made DIM  textlist(80, 80).  (= 6400 char)
> instead of textlist(30, 30)  it said "OUT OF RANGE" or
> "OUT OF STRINGSPACE"
[...]
> DIM SHARED textlist(1 TO 81, 1 TO 81) AS STRING         ' init 2D

You just want store _one_ character at a position, so you avoid using
dynamic strings; instead use fixed strings of 1 character:

DIM SHARED textlist(1 TO 81, 1 TO 81) AS STRING * 1

should solve your problem. :-)

      Andreas



Thu, 24 Jun 2004 05:17:22 GMT  
 Array's TOO BIG??


Quote:
> Hi there,

Hello Marco,

[Snip]

Quote:
> BUT when I made DIM  textlist(80, 80).  (= 6400 char)

Uh, oh .... If you create an Array that way (pointing to strings of
*Un-defined length's*) BASIC will have to create an *intermediate* array
pointing to those strings.  Every cell in that intermediate array will in
turn hold a *pointer to a string* (pointing into String-space) and *it's
length*.  This means that every cell in that intermediate array will be at
least 4 bytes of size, making it at least 25600 bytes of size ...

And that's the problem you bump into, not the stings themselves (which are,
at the moment of creation of the Array, not even present.)

Andreas gave you the correct solution to your problem.

The reason why is that when you create an Array with *fixed-size* elements,
BASIC does not have to store the length with every element created and can
*calculate the position* of the stored element-data by multiplying the
element-index by the size of a single element.  This means that it does *not
need pointers* to every element.  So, no intermediate Array is needed ...

Regards,
  Rudy Wieser



Thu, 24 Jun 2004 18:40:40 GMT  
 Array's TOO BIG??
SUPER,

Two key presses and it worked.  .........* 1..............

Thanks a lot Andreas



Thu, 24 Jun 2004 20:35:31 GMT  
 Array's TOO BIG??
OK Thanks Rudy.

I have it already fixed.

It is always good  to know  what the difference is between " * 1" and
just "   " and what it really means

My Star LC-10 is printing fine now!!! Need to fix  some other stuff.
But the big idea is working now. Heheheeee.....

Marco



Thu, 24 Jun 2004 22:10:22 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help with BIG array

2. Memory management and big array in PowerBASIC or QuickBASIC : Help

3. Again: QBasic w/ big arrays?

4. QBasic w/ big arrays?

5. Array index.......determine biggest value..

6. BIG Persistent array in VB ActiveX DLL

7. BIG Persistent array in VB ActiveX DLL

8. Allocating very BIG arrays

9. Big Array Initializations Problems

10. How to pass a big array from VB5 to VC5++ DLL

11. Runtime Error #7 - Big global string arrays

12. Passing Big Arrays To GRID

 

 
Powered by phpBB® Forum Software