SElib.pointer()
syntax: |
SElib.pointer(varName) |
where: |
varName - the name or identifier of a variable
|
return: |
number - the address of, a pointer to, the variable identified by varName.
|
description: |
Gets the address in memory of a variable. The pointer points to the first byte of data in a variable. The variable may be a primitive data type: byte, integer, or float, or it may be a single dimension array of bytes, integers, or floats, which includes a string. If the variable is an array, then the address returned points to the first byte of the first element of the array. The parameter varName may also identify a Blob variable since Blobs are actually byte arrays. Other types of data are not allowed.
For computer architectures that distinguish between near and far memory addresses, the value returned by SElib.pointer() is a far address or pointer.
ScriptEase data is guaranteed to remain fixed at its memory location only as long as that memory is not modified by a script. Thus, a pointer is valid only until a script modifies the variable identified by varName or until the variable goes out of scope in a script. Putting data in the memory occupied by varName after such a change is dangerous. When data is put into the memory occupied by varName, be careful not to put more data than will fit in the memory that the variable actually occupies.
Caution. Routines that work with memory directly, such as this one, should be used with caution. A programmer should clearly understand memory and the operations of these methods before using them. ScriptEase does not trap errors caused by this routine.
|
see: |
SElib.peek(), SElib.poke(), Clib.memchr(), Blob object
|
example: |
var v = "Now"; // Display "Now" Screen.writeln(v); // Get the "N" var vPtr = SElib.pointer(v); // Get the address of the first byte of v, "N" var p = SElib.peek(vPtr); // Convert "N" to "P" SElib.poke(vPtr,p+2); // Display "Pow" Screen.writeln(v);
// See usage in fileobj.jsh, batch.jsh, // memsrch.jsh, touch.jsh, and pickfile.jsh |