Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need more memory? 1

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
Getting out of memory errors, but yor computer doesn't have EMS, XMS, or you just don't know how to use them?

This is a cheat trick that I just thought of, I am not sure if it is great, but I can't see of a reason it wouldn't work.
This can only be done in a multitasking OS

use this code
'$DYNAMIC
DIM array(16383)
OPEN "mem.tmp" FOR RANDOM AS #1
PUT #1,1,VARSEG(array)
PUT #1,2,VARPTR(array)
CLOSE
WHILE INKEY$ = "":WEND
KILL "mem.tmp"

'now leave this program running as you run another qbasic program, you can use array() but POKEing and PEEKing to it, since the information you need to access it is in "mem.tmp" - presto: 64 extra kilobytes!

"You idiots, teacher was trying to teach you to be great artists, but you've only learned to be great mimics"
-Unknown taoist artist
Originality is the key to greatness
 
I just did yes, and it seems to work like a charm, I made a slight mistake coding it though'$DYNAMIC
you can not simply PUT a VARSEG statement, you have to fist put it into a variable

DIM array(16383)
OPEN "mem.tmp" FOR RANDOM AS #1
s = VARSEG(array)
PUT #1,1,s
p = VARPRT(array)
PUT #1,2,p
CLOSE
WHILE INKEY$ = "":WEND
KILL "mem.tmp"


"You idiots, teacher was trying to teach you to be great artists, but you've only learned to be great mimics"
-Unknown taoist artist
Originality is the key to greatness
 
Have you tried accessing the Array() memory space from a different program?

[flush2] TANSTAAFL [reading]




Real men don't use Interrupt 21h.
 
Yes, the RAM of that space is cleared (0's all the way through), and Windows will make sure that no other program tries to use it, so you can POKE directly to it and have no fear of screwing with other programs' memory or of having other programs screw with it.

"You idiots, teacher was trying to teach you to be great artists, but you've only learned to be great mimics"
-Unknown taoist artist
Originality is the key to greatness
 
I just wondered if you are looking at valid data.
The memory addresses returned by VARSEG and VARPTR are integer values, which are two bytes in length. When you save the segment to mem.tmp with [tt]PUT #1,1,s[/tt] you immediately overwrite the second byte of the "s" variable with the first byte of the "p" variable with [tt]PUT #1,2,p[/tt].

Have you tried to verify all of this by filling the [tt]Array()[/tt] array with a distinct pattern of values in the first program and reading them back through the second program?

Please show us the rest of your code.


Real men don't use Interrupt 21h.
 
For Extra memory,you should rather use SVGAQB.LIB from : EMS , XMS access functions are predefined and really FAST !! (I think that's not the first time I say that...)
[pc3]
 
DIM array%(32766) 'same as above, just integer
OPEN "mem.tmp" FOR RANDOM AS #1
s% = VARSEG(array)
PUT #1,,s%
p% = VARPRT(array)
PUT #1,,p%
CLOSE
FOR a = 0 to 10
array%(a) = 65535 '1111111111111111 in binary
NEXT
WHILE INKEY$ = "":WEND
KILL "mem.tmp"

*****different program*****
OPEN m"mem.tmp" FOR RANDOM AS #1
GET #1,,s%
GET #1,,p%
CLOSE
DEF SEG = s%
a = PEEK p% 'keep in mind PEEK only gives you 1 byte
PRINT a
a = PEEK p%+1
PRINT a
'you should get 255 and 255 - 11111111 in binary


EMS and XMS are great, but I have been looking for a long while, and I've never found one that worked under Windows XP and some computers have no EMS


"You idiots, teacher was trying to teach you to be great artists, but you've only learned to be great mimics"
-Unknown taoist artist
Originality is the key to greatness
 
However I didn't mean to use the array% space that way, I was pointing out that because it is all empty it could be used by the second program using PEEK and POKE.

The only thing to rememeber is that you are POKEing 2-byte integers and PEEKing one byte at a time

"You idiots, teacher was trying to teach you to be great artists, but you've only learned to be great mimics"
-Unknown taoist artist
Originality is the key to greatness
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top