System Functions
MEM( ) Return Memory Value
   
Formats
1. Get Address of String: MEM(var$[,ERR=stmtref])
2. Read Memory, 2 Bytes: MEM(address[,ERR=stmtref])
3. Read Memory, 'n' Bytes: MEM(address,bytes[,ERR=stmtref])
4. Change Memory: MEM(address,val$[,ERR=stmtref])

Where:

var$ Name of string variable whose address you wish to obtain.
address Number of bytes to return. (Numeric expression)
val$ Value you wish to write. (String expression)
stmtref Program line number or statement label to which to transfer control should an error occur.
Returns Memory location and/or value.


*Note* This function is mainly for use with external functions; i.e., using the functions DLL( ) and DLX( ) Call Windows DLL/DLX.


   
Description The MEM( ) function provides direct access to memory locations through the use of pointers. The return value is dependant on the format used:
  • Format 1 returns a numeric value with the address of your string variable.
  • Format 2 returns a numeric value which has the contents of a word (16 bits) of memory. The value returned is a binary value (integer in two's complement format).
  • Format 3 returns a string consisting of the data at the address specified for the specified number of bytes. If the number of byte specified is zero (0), the function returns all data starting at the specified address up to the first NULL byte. This is handy when used to retrieve null terminated strings which are a common format used with system calls.
  • Format 4 copies your character string value to the address given. The function returns a the value of the string val$

Where possible (primarily Windows) the system performs address validation and returns Error #41: Invalid integer encountered (range error or non-integer) for an invalid memory location. If address validation is not possible, use of an invalid address may cause the application to abort.