ScriptEase Professional Library

The routines in this section are not for the timid. They are included internally to the ScriptEase program, and are available to any ScriptEase program under any operating system.

Most of these routines allow the programmer to have more power than is generally acknowledged as safe under ScriptEase' guidelines. Be cautious when you use these commands, they provide plenty of rope with which to hang yours


InterpretInNewThread

DESCRIPTION

Interpret a script in a new thread of current ScriptEase process.

SYNTAX

int InterpretInNewThread(string filename, string textToInterpret)

COMMENTS

This function creates a new thread within the current ScriptEase

process and interprets a script within that new thread. The new script will run independently of the currently executing thread. This differs from interpret() in that the calling thread will not wait for the interpretation to finish, and it differs from spawn() in that the new thread will run in the same memory and process space as the currently running thread.

It is up to the script writer to ensure any synchronization between threads; ScriptEase data and globals will be per-thread only.

If filename is not NULL then it is the name of a file to interpret and

textToInterpret will be parsed as if they are command-line parameters to the main() function. If filename is NULL then textToInterpret will be treated as pure ScriptEase code and interpreted directly.

RETURN

Returns the ID number of the thread containing the new instance of ScriptEase. If there is an error, 0 or -1 will be returned, depending on the operating system.

NOTE

This function is not supported on operating systems that do not support multithreading, such as DOS and 16-bit Windows.


peek
 

DESCRIPTION

Read data from memory location.

SYNTAX

byte peek(int address) byte peek(int address,int DataType=UWORD8) int peek(int address,int DataType) float peek(int address,int DataType) byte[] peek(int address,int bufferLen) struct BLObGet(int address,struct DataStructureDefinition)

COMMENTS

Reads data from the specified address in memory, where address is a memory pointer. This function is similar to the BLObGet function, with "address" replacing the "blob BLObVar,int offset" parameter pair. If DataType is not specified then UWORD8 is assumed. Valid data types are: UWORD8, SWORD8, UWORD16, SWORD16, UWORD24, SWORD24, UWORD32, SWORD32, FLOAT32, FLOAT64, FLOAT80 See fread() in the Standard Library (Chapter 5) for more information on these DataType values.

RETURN

Returns the byte, int, float, or byte[] that was read from the specified memory location.

SEE ALSO

Address(), _BigEndianMode, fread(), poke()


pointer
 

DESCRIPTION

Get address of variable array or variable datum.

SYNTAX

int pointer(var)

COMMENTS

This function returns the actual address in memory where the var data is stored. If var is a byte, int, or float, then this will return the address in memory of that byte, int, or float datum. If var is an single-dimensional array of bytes, ints, or floats, then this will return the address of the first element of that array (BLObs are okay because a blob is really a byte array). No other types, undefined, structures, or multidimensional arrays, are allowed for var. In other words, var must be a numeric data type, or a pointer to an array of numeric data.

For architectures that distinguish between near and far memory addresses, the value returned by pointer() is a far address. :

WARNING

ScriptEase data is only guaranteed to remain fixed at its memory location if that memory is not modified by your ScriptEase code. So, the pointer is valid only until ScriptEase code modifies var or until it goes out of scope. Writing to the data at this pointer is not recommended, and if you do write to the memory then be sure to not write more data than already fits in var.

RETURN

Returns pointer to the datum or data in var.

SEE ALSO

offset(), segment()

EXAMPLE

This function prepares a BLOb that may be passed to a call into the operating system:

// Assume there is an OS call that will perform a command

// on a number of files. This call expects to receive a

// C-defined packed structure like this:

// struct {

// unsigned charFileCount;

// char *Command; // Command to perform on files

// char *FileName[1]; // array of pointers to file

// names

};

 

// Now prepare such a structure BLObPut(Data,2,UWORD);

// how many names follow BLObPut(Data,pointer("DEL"),UWORD32);

// set command

BLObPut(Data,pointer("C:\\UTL\DOG"),UWORD32);

BLObPut(Data,pointer("C:\\UTL\\CAT"),UWORD32);


poke
 

DESCRIPTION

Write data to memory location.

SYNTAX

int poke(int address,byte b) int poke(int address,Var v,int DataType) int poke(int address,byte[] buffer,int bufferLen) int poke(int address,struct SrcStruct,struct DataStructureDefinition)

COMMENTS

Write value at the specified location in memory, where address is a memory pointer. This function is similar to the BLObPut function, with "address" replacing the "blob BLObVar,int offset" parameter pair. If DataType is not specified then UWORD8 is assumed. Valid data types are: UWORD8, SWORD8, UWORD16, SWORD16, UWORD24, SWORD24, UWORD32, SWORD32, FLOAT32, FLOAT64, FLOAT80 See fread() in the Standard Library (Chapter 5) for more information on these DataType values.

RETURN

Address of byte following the data just poked.

SEE ALSO

Address(), _BigEndianMode, fread(), peek()