QB45-String Space Corrupt 
Author Message
 QB45-String Space Corrupt

I recently encountered a String Space Corrupt problem in a database sorting
program using QB45. I found a way around the problem, but I'm still looking for
answers and/or comments.

This is what I did and my solution:

First I started QB with the /ah option. This allows large arrays using far
pointers.
Here is some psudo code:

qty = 10000
DIM array(qty) as STRING * 16
for a = 1 to qty
    array(a) = ( info to be sorted along with the value of a )
next
do
    if condition exists then
         SWAP array(a), array(b)
    end if
loop until fully sorted
OPEN "file" for output as #1
for c = 1 to qty    
    print #1, value of a from  array(c)
next
close #1

As soon as it hit the SWAP command it either crashed the computer or a gave a
string space corrupt message and dumped QB45. I did the same thing on 2
computers. It worked better with smaller arrays. It also helped if I inserted
dummy delay loops. These solutions were unacceptable. It seems that QB45 can't
shift data in and out of array elements in large arrays very fast without
getting caught up somehow.
To solve the problem I had the program sort pointers instead of array elements.
It workes great! All I need are the sorted pointers. Here is an idea of what I
did:

qty = 10000
DIM array(qty) as STRING * 16
DIM ptr(qty)
for a = 1 to qty
    array(a) = ( info to be sorted)
    ptr(a) = a
next
do
    if condition comparing array(ptr(a))   array(ptr(b))    exists then
         SWAP ptr(a), ptr(b)
    end if
loop until fully sorted
OPEN "file" for output as #1
for c = 1 to qty    
    print #1,ptr(c)
next
close #1

Anyone ever have a similar problem? Any other solutions/comments?

Bob Radil



Thu, 03 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt


Quote:
(BobRadil) writes:
>This is what I did and my solution:
>First I started QB with the /ah option. This allows large arrays using
>far pointers. Here is some psudo code:
>qty = 10000
>DIM array(qty) as STRING * 16

<snip>

So where's the '$DYNAMIC metacommand, that array is Static and
limted to 64 kb.

<snip>

Quote:
>As soon as it hit the SWAP command it either crashed the computer
>or a gave a string space corrupt message and dumped QB45. I did
>the same thing on 2 computers. It worked better with smaller arrays.

Not surprising since you only seem to be using static arrays :)

Quote:
>It also helped if I inserted dummy delay loops. These solutions were
>unacceptable. It seems that QB45 can't shift data in and out of array
>elements in large arrays very fast without getting caught up somehow.

Try enabling '$dynamic arrays, de-allocate all unused arrays before
sorting and check any code prior to your sort routine, this may be
the culprit and not the actual sort routine itself.
The string space corrupt message does not always occur at the point
in the code where the actual corruption was produced.

<snip>

Quote:
>Anyone ever have a similar problem? Any other solutions/comments?

You could also try using an alternative, slower swap, assuming that
element 0 is unused -

  array(0) = array(a)
  array(a) = array(b)
  array(b) = array(0)

TTfn,

Craig___



Thu, 03 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt

I'm not sure if this is pertinent, but I had a similar problem.  The
use of the /ah allows "dynamic" arrays to be larger and up to 64K so I
had to use the "REDIM" instead of the "DIM" to make sure that my
arrays were dynamic.  Also, I had to use the "REM $DYNAMIC"
metacommand.

Give it a try, it might help.


Quote:
>I recently encountered a String Space Corrupt problem in a database sorting
>program using QB45. I found a way around the problem, but I'm still looking for
>answers and/or comments.

>This is what I did and my solution:

>First I started QB with the /ah option. This allows large arrays using far
>pointers.
>Here is some psudo code:

>qty = 10000
>DIM array(qty) as STRING * 16
>for a = 1 to qty
>    array(a) = ( info to be sorted along with the value of a )
>next
>do
>    if condition exists then
>         SWAP array(a), array(b)
>    end if
>loop until fully sorted
>OPEN "file" for output as #1
>for c = 1 to qty    
>    print #1, value of a from  array(c)
>next
>close #1

>As soon as it hit the SWAP command it either crashed the computer or a gave a
>string space corrupt message and dumped QB45. I did the same thing on 2
>computers. It worked better with smaller arrays. It also helped if I inserted
>dummy delay loops. These solutions were unacceptable. It seems that QB45 can't
>shift data in and out of array elements in large arrays very fast without
>getting caught up somehow.
>To solve the problem I had the program sort pointers instead of array elements.
>It workes great! All I need are the sorted pointers. Here is an idea of what I
>did:

>qty = 10000
>DIM array(qty) as STRING * 16
>DIM ptr(qty)
>for a = 1 to qty
>    array(a) = ( info to be sorted)
>    ptr(a) = a
>next
>do
>    if condition comparing array(ptr(a))   array(ptr(b))    exists then
>         SWAP ptr(a), ptr(b)
>    end if
>loop until fully sorted
>OPEN "file" for output as #1
>for c = 1 to qty    
>    print #1,ptr(c)
>next
>close #1

>Anyone ever have a similar problem? Any other solutions/comments?

>Bob Radil

Barry Eggers
eggers1 AT tsil DOT net


Fri, 04 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt

Quote:

>So where's the '$DYNAMIC metacommand, that array is Static and
>limted to 64 kb.

The $DYNAMIC metacommand is not nessessary here since I started QB with the /ah
option and the array was dimensioned with the  variable (qty). This makes it
dynamic.  The array was successfully dimensioned to a size of 160K.

Quote:
>You could also try using an alternative, slower swap, assuming that
>element 0 is unused -

>  array(0) = array(a)
>  array(a) = array(b)
>  array(b) = array(0)

I tried that in a previous situation and it worked, but when I tried it in this
case it just delayed the inevitable crash.

Thanks for your input,

Bob



Fri, 04 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt

If you are sure that all the arrays are dynamic then the "String Space
Corrupt" probably refers to normal strings.  The swap command is
setting up a new temporary string to do the swap.  Try putting the FRE
command at strategic places in your program to check out what your
normal strings are doing.  It may not be the arrays.

If you are getting the corruption in the IDE and not in the compiled
program, you might have to remove some of your REM statements.  I
found that they will use some of your string space.

Barry

Quote:

>>I recently encountered a String Space Corrupt problem in a database sorting
>>program using QB45. I found a way around the problem, but I'm still looking for
>>answers and/or comments.

>>This is what I did and my solution:

>>First I started QB with the /ah option. This allows large arrays using far
>>pointers.
>>Here is some psudo code:

>>qty = 10000
>>DIM array(qty) as STRING * 16
>>for a = 1 to qty
>>    array(a) = ( info to be sorted along with the value of a )
>>next
>>do
>>    if condition exists then
>>         SWAP array(a), array(b)
>>    end if
>>loop until fully sorted
>>OPEN "file" for output as #1
>>for c = 1 to qty    
>>    print #1, value of a from  array(c)
>>next
>>close #1

>>As soon as it hit the SWAP command it either crashed the computer or a gave a
>>string space corrupt message and dumped QB45. I did the same thing on 2
>>computers. It worked better with smaller arrays. It also helped if I inserted
>>dummy delay loops. These solutions were unacceptable. It seems that QB45 can't
>>shift data in and out of array elements in large arrays very fast without
>>getting caught up somehow.
>>To solve the problem I had the program sort pointers instead of array elements.
>>It workes great! All I need are the sorted pointers. Here is an idea of what I
>>did:

>>qty = 10000
>>DIM array(qty) as STRING * 16
>>DIM ptr(qty)
>>for a = 1 to qty
>>    array(a) = ( info to be sorted)
>>    ptr(a) = a
>>next
>>do
>>    if condition comparing array(ptr(a))   array(ptr(b))    exists then
>>         SWAP ptr(a), ptr(b)
>>    end if
>>loop until fully sorted
>>OPEN "file" for output as #1
>>for c = 1 to qty    
>>    print #1,ptr(c)
>>next
>>close #1

>>Anyone ever have a similar problem? Any other solutions/comments?

>>Bob Radil

Barry Eggers
eggers1 AT tsil DOT net


Sat, 05 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt


Quote:
(BobRadil) writes:
>>So where's the '$DYNAMIC metacommand, that array is Static and
>>limted to 64 kb.
>The $DYNAMIC metacommand is not nessessary here since I started
>QB with the /ah option and the array was dimensioned with the  variable
>(qty). This makes it dynamic.  
>The array was successfully dimensioned to a size of 160K.

Errrr, the example you posted was static regardless of using the /AH
as you used a DIM instead of a REDIM -
  qty = 10000
  DIM array(qty) as STRING * 16  
It's not possible to set it to 10 000 elements :)

Quote:
>>You could also try using an alternative, slower swap, assuming that
>>element 0 is unused -
>>  array(0) = array(a)
>>  array(a) = array(b)
>>  array(b) = array(0)
>I tried that in a previous situation and it worked, but when I tried it in
>this case it just delayed the inevitable crash.

I got that wrong, using SWAP with Types and/or strings is often slower
than the above manual swap, something to do with temporary string
allocation/de-allocation ?

TTfn,

Craig___



Sat, 05 Aug 2000 03:00:00 GMT  
 QB45-String Space Corrupt

Let me just add that I had no problem DIMming the array to 160K. There are 2
ways to do this. Both require the  /ah option. One way is to use the "$DYNAMIC
meta command. The other, which I used is to use a variable in the DIM command.
This creates an array that uses far pointers and goes outside of the BASIC data
segment.

Example:
qty = 10000
DIM array$(qty) as string * 16

This won't work:
DIM array$(10000)as string * 16

The problem was sorting the elements of the array.
I don't recall DIM or REDIM making a differance, but I can try REDIM again. It
still seems to be a shortcoming of QB45. If it is then others should have the
same problem.

Upon giving it more thought, my solution of SWAPping 16 bit integers used to
point to the array elements should be much faster than SWAPping 16 byte
strings.

Thanks for the comments,
Bob Radil



Sat, 05 Aug 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. QB45 with Assembler: String Space Corrupt!

2. Corrupted String Space Problem

3. String Space Corrupt error: Solved!

4. "String Space Corrupt" in QB 4.5

5. string space corrupt error

6. Space Space Space Space Space Space Space

7. Space Space Space Space Space Space Space

8. Space Space Space Space Space Space Space

9. Free Space in QB45

10. disabling the space key or removing a space from a string

11. Function to Squeeze multiple spaces in a string to one space

12. string replace with wildcard number of spaces between strings - removing blank lines

 

 
Powered by phpBB® Forum Software