LIST MEMORY

Sys(2600)

If you have experience with other programming languages, you might be familiar with the peek/poke concept. If you're not familiar with peek/poke, you'll be happy to know that it has nothing to do with looking at pigs in a sack (peeking at pigs in a poke? Oh, never mind). It means that you can look at a specific memory location (peek), or put a value into a specific location in memory (poke). Finally, beginning in VFP 7, we have the ability to manipulate memory directly.

Usage

cContents = SYS( 2600, nAddress, nNumberOfBytes              [ , cValueToPoke ] )

Parameter

Value

Meaning

nAddress

Numeric

The address of the location in memory.

nNumberOfBytes

Numeric

How many bytes to return/write.

cValueToPoke

Omitted

Return the value in the specified location in memory (peek).

Character

"Poke" the value into the specified location in memory.

cContents

Character

The value in memory.


I hope you're an advanced programmer (you probably are if you're still reading this topic). Help specifically says this is "for advanced programmers only." Actually, you'd better be advanced—the ability to write to any location in memory can really clobber whatever's in memory on your machine. However, you'll probably find this useful if you're working with API functions that return pointers to memory buffers, and the memory contains the value you're after. Now that we can peek and poke memory, hopefully the wizards at Microsoft will let us scratch and sniff it in VFP 8.

Hats off to the Fox team for their excellent choice of numbers for this SYS function.

Example

* Because you can really hose your system, we won't give an  * example that you can cut and paste and potentially trash your * system. Instead, we'll point you to an example shipped with * FoxPro. Execute the following, and you'll see the * code that reads memory: SELECT 0 USE HOME() + "foxcode" AGAIN SHARED LOCATE FOR Expanded = "GetEnv" MODIFY MEMO Data * And, yes, the "PROCEDURE Destory" on line 31  * really should be "Destroy".

See Also

Sys()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net