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()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .