Huge Arrays 
Author Message
 Huge Arrays

Once and for all, I'm determined to get Huge Arrays to work under
QB45.  (I need them to work with strings read from a file.)

Here is my first attempt (source file is 2.BAS):

        DIM ar(1400) AS STRING * 64
        OPEN "xx" FOR INPUT AS #1
        FOR i = 1 TO 1400
        LINE INPUT #1, ar(i)
        NEXT i: CLOSE: END

Running  QB 2 /AH  gives a "Subscript out of range" error,
and  BC 2 /AH  says "Array too big" while pointing at the
64 in the first line.

The file xx contains 1400 lines each consisting of the same 56
characters (making it exactly 64 characters doesn't help).

What am I doing wrong?  Please help.

George



Thu, 25 May 2000 03:00:00 GMT  
 Huge Arrays

Quote:

> Once and for all, I'm determined to get Huge Arrays to work under QB45.
> Here is my first attempt (source file is 2.BAS):
> What am I doing wrong?  Please help.

You forgot the magic word .....

'$DYNAMIC

Quote:

>         DIM ar(1400) AS STRING * 64
>         OPEN "xx" FOR INPUT AS #1
>         FOR i = 1 TO 1400
>         LINE INPUT #1, ar(i)
>         NEXT i: CLOSE: END

... should work now!


Fri, 26 May 2000 03:00:00 GMT  
 Huge Arrays

Quote:

> Once and for all, I'm determined to get Huge Arrays to work under
> QB45.  (I need them to work with strings read from a file.)

Why would you want this? If what you're doing is important (I mean
serious) you'll never will be able to allocate enough memory to do it.
I am thinking of the telephone guide of some city.
Why not invest in a array-buffer and file approach. That will work with
any amount of data, even when the amount doubles over time (or more in
ways you didn't expect before hand).
You can set the array buffer to any size, so when you come across a way
on maximizing memory for the array, the file(s) won't be used.

Still having nu clue what you intend is, I'd like to remark that it
could be exactly this attitude, just claiming as much memory as
available, that makes Windows programs, even the simplest of all using
enormuos amounts of memory. An editor would take up more memory then
the earliest Turbo-Pascal compiler for the original PC's.

Marnix.



Fri, 26 May 2000 03:00:00 GMT  
 Huge Arrays

|> >
|> > Once and for all, I'm determined to get Huge Arrays to work under
|> > QB45.  (I need them to work with strings read from a file.)
|>
|> Why would you want this? [...]
|>
|> Still having nu clue what you intend is, I'd like to remark that [...]

Now there is the right approach to "answering" a request
for information:

 1) Give no information.
 2) Admit that you don't have a clue what the poster is thinking,
    and then remark on a wholly unrelated topic.

So, in case, this request hasn't been fully dealt with,
here are some rules for getting QB45 to work with HUGE arrays:

- You must use the /ah command parameter when invoking
  QB.EXE. If you compile and link from the command line,
  invoke BC.EXE with the /ah option. No special option
  is required for LINK.EXE.

- If the size of your array elements are not a power of 2
  (eg. 2, 4, 8, 16, 32...) then your HUGE array is limited
  to a total size of 128K, or less. This limit applies only
  when the array elements are TYPEs or fixed strings,
  since all numeric variables have a length that is a power
  of 2.

- There is a slight speed penalty for using HUGE arrays,
  since your program will substitute a slower array handling
  routine for the default (faster) routine and then use
  the slower routine for all your arrays. So, it doesn't
  pay to use /ah unless you have to use it.

On a related note: If I recall correctly, QB45 doesn't allow
you to directly create an array of nothing but fixed-strings.
Instead, you must work around this limitation, by creating
a TYPE that consists of a fixed string and DIM an array of
that TYPE:

  TYPE Str128
     Data  AS STRING * 128
  END TYPE

  DIM FString (1 TO 5000) AS Str128

  FString(1).Data = "A short string in a long space"

--
Brian McLaughlin, Technical Writer  |"Thanks to the Internet, misinformation
Integrated Measurement Systems, Inc.| now travels faster than ever before!"
Beaverton, OR, USA                  | ---- Standard disclaimer applies ----



Sat, 27 May 2000 03:00:00 GMT  
 Huge Arrays

GH>Once and for all, I'm determined to get Huge Arrays to work under
GH>QB45.  (I need them to work with strings read from a file.)

GH>Here is my first attempt (source file is 2.BAS):

GH>        DIM ar(1400) AS STRING * 64
GH>        OPEN "xx" FOR INPUT AS #1
GH>        FOR i = 1 TO 1400
GH>        LINE INPUT #1, ar(i)
GH>        NEXT i: CLOSE: END

   George,

   Looks okay. I added the ' $DYNAMIC metacommand that will make the array
   dynamic (versus static - see the QB online help for more info on -
   Dynamic vs. Static arrays). Here's my test-your-code code that worked
   for me in PDS 7.1

' ----------- CUT HERE -------------------------------- CUT HERE ---------
REM You must start QB\PDS with the /AH command line option for this program

' $DYNAMIC   ' array space allocated when program is run - see QB onlinehelp

OPEN "xx" FOR OUTPUT AS #1
REM Create a 1400 line file with 56 character a's on each line
FOR I% = 1 TO 1400
    PRINT #1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
NEXT I%
CLOSE #1

DIM ar(1400) AS STRING * 64
OPEN "xx" FOR INPUT AS #1
FOR I = 1 TO 1400
    LINE INPUT #1, ar(I)   ' load up the array
NEXT I
CLOSE #1

REM Let's dump the array contents and have a look-see
FOR I% = 1 TO 1400
    PRINT ar(I%)
NEXT I%
END  ' All done. The End.
' ----------- CUT HERE -------------------------------- CUT HERE ---------

GH>Running  QB 2 /AH  gives a "Subscript out of range" error,
GH>and  BC 2 /AH  says "Array too big" while pointing at the
GH>64 in the first line.

GH>The file xx contains 1400 lines each consisting of the same 56
GH>characters (making it exactly 64 characters doesn't help).

  Why not simply put that single line of 56 characters in the file,
  read it in and then stuff it into the array 1400 times, as in:

' ------------ CUT HERE ----------------------------- CUT HERE -----------
' $DYNAMIC
TheLine$ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
OPEN "xx" FOR OUTPUT AS #1
PRINT #1, TheLine$   ' write 1 line of data to the data file
CLOSE #1

DIM ar(1400)
OPEN "xx" FOR INPUT AS #1
LINE INPUT #1, TheLine$  ' get that single line of 56 characters
CLOSE #1
FOR I% = 1 TO 1400
    ar(I%) = TheLine$    ' load up the array with the 56 character string
NEXT I%

FOR I% = 1 TO 1400       ' let's dump the array and have a look-see
    PRINT ar(I%)
NEXT I%
' ------------ CUT HERE ----------------------------- CUT HERE -----------

Hope that helps. Good luck!

- Robert

 * OLX 2.1 TD * "I'm mad as hell and I'm not gonna take it anymore!!!!"



Sat, 27 May 2000 03:00:00 GMT  
 Huge Arrays

Quote:



>|> >
>|> > Once and for all, I'm determined to get Huge Arrays to work under
>|> > QB45.  (I need them to work with strings read from a file.)
>|>
>|> Why would you want this? [...]
>|>
>|> Still having nu clue what you intend is, I'd like to remark that [...]
>Now there is the right approach to "answering" a request
>for information:
> 1) Give no information.
> 2) Admit that you don't have a clue what the poster is thinking,
>    and then remark on a wholly unrelated topic.

He, whats up Brian: that was my point for more then a year now..!
Also I think that Marnix  might not already know that when running
DOS he probably has 8 MB or more xms waiting to be used, appart
from the conventional mem that is. And now anybody might go on
telling me that 8 MB for data for a program is not enough of course..
[I don't know about the phonebook: my city is not that big..]

Rick



Sat, 27 May 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. . qb and pb huge arrays

2. Huge Array File I/O VB/API

3. Creating a Huge Array (VB 3)

4. Huge Arrays in VB for DOS

5. Huge Array killing VB

6. Reading Huge Array From File Directly Into VB

7. Initialising Huge Array Contants

8. How to read huge arrays

9. Newbie Q:Structure of VB 3.0 Huge Arrays

10. How to declare/use a huge array?

11. Help with huge array declaration!

12. help Problems with huge arrays

 

 
Powered by phpBB® Forum Software