|
Post by earlofqb on Aug 29, 2006 21:52:15 GMT
PEEK and POKE access memory addresses and allow you to move bits around. There isn't anything overwhelmingly like the stuff you can do in C/C++, however. I think all versions of QB can use these functions. I'll shut up now, as I've never used these funcitons in QB (and as such, making a fool of myself ).
|
|
|
Post by Mikrondel on Aug 29, 2006 21:58:06 GMT
Great! I also love C/C++. So I command you to remain here Now, yes, QB does allow you to access memory, although the method is a little tricky. Firstly you use DEF SEG = ... to set the default memory segment. It's a 16-bit thing. Unless you know what the memory segment is (DEF SEG = &HA000 to access video memory) you'll probably use VARSEG(variable) to find its memory segment. So supposing... DIM Array (0 TO 127) AS INTEGER DEF SEG = VARSEG(Array(0)) Now, you can use PEEK and POKE to read or write the memory respectively. Use VARPTR(variable) to find the variable's pointer within its memory segment. FOR i = 0 TO 255 POKE VARPTR(Array(0)) + i, i NEXT FOR i = 0 TO 255 PRINT PEEK(VARPTR(Array(0)) + i) NEXT It is recommended you place just a "DEF SEG" to restore the default segment when you're done. Quick note: INTEGERs are 2 bytes long. You can declare arrays of "STRING * 1" if you want, effectively, char arrays. If you want any more help then please ask.
|
|
|
Post by Mikrondel on Aug 30, 2006 6:00:37 GMT
Oh my goodness, you've so just been upgraded to the Regulars group. I hope you choose to stay here
|
|
|
Post by TomyYoung on Jun 18, 2015 17:17:45 GMT
cool qbasic
|
|