MEMORY

Purpose: Provides access to an array of values stored in memory.

Format:   MEMORY(location)

Notes:    The  MEMORY  function  is used to retrieve or store individual values within a block of computer memory.  This is useful when several values must be accessed and individual variable name assignments are not practical.  The  location  parameter is used to indicate the position of the value within the computer memory.  MEMORY  values may be used directly within formula statements.  All values are stored as floating point  numbers, Integer and byte formats may be specified by using the  OPEN  statement.  A  MEMORY  expression can not be used directly within a print statement.

Examples:

# Set a block of 100 memory values to zero
clear
print "Zeroing out memory..."
a = 0
loop begin 100
memory(a) = 0
a = a + 1
loop end
gosub displaymem

# Each memory values = it's location.
clear
print "Value = Location"
a = 0
loop begin 100
memory(a) = a
a = a + 1
loop end
gosub displaymem

# Square each memory value.
clear
print "Square Root of each memory value"
a = 0
loop begin 100
memory(a) = sqrt(memory(a))
a = a + 1

loop end
gosub displaymem

# Access an individual location.
*access
input loc "Enter a memory location"
val = memory(loc)
pause " The value in location " loc " is " val
goto access

exit

*DisplayMem
print "Location - Value"
print "________________"
loc = 0
*memloop
val = memory(loc)
print "    " loc "       " val
loc = loc + 1
if loc < 20
goto memloop
endif
pause
return

See Also:  ALLOCATE  OPEN    READ  WRITE