(self, name, dimensions)
Allocate array space for an array of given dimensioned size.
        Raise errors if duplicate name or illegal index value.
Allocate array space for an array of given dimensioned size.
        Raise errors if duplicate name or illegal index value.
Allocate array space for an array of given dimensioned size . Raise errors if duplicate name or illegal index value .
def allocate(self, name, dimensions):
        """
        Allocate array space for an array of given dimensioned size.
        Raise errors if duplicate name or illegal index value.
        """
        if not dimensions:
            # DIM A does nothing
            return
        if self._base is None:
            self._base = 0
        if name in self._dims:
            raise error.BASICError(error.DUPLICATE_DEFINITION)
        for d in dimensions:
            if d < 0:
                raise error.BASICError(error.IFC)
            elif d < self._base:
                raise error.BASICError(error.SUBSCRIPT_OUT_OF_RANGE)
        # update memory model
        name_ptr = self.current
        record_len = self._record_size(name, dimensions)
        array_bytes = self._buffer_size(name, dimensions)
        array_ptr = name_ptr + record_len
        total_bytes = record_len + array_bytes
        self._memory.check_free(total_bytes, error.OUT_OF_MEMORY)
        self.current += total_bytes
        self._array_memory[name] = (name_ptr, array_ptr)
        self._buffers[name] = bytearray(array_bytes)
        self._dims[name] = dimensions
def allocate ( self , name , dimensions ) : if not dimensions : # DIM A does nothing return if self . _base is None : self . _base = 0 if name in self . _dims : raise error . BASICError ( error . DUPLICATE_DEFINITION ) for d in dimensions : if d < 0 : raise error . BASICError ( error . IFC ) elif d < self . _base : raise error . BASICError ( error . SUBSCRIPT_OUT_OF_RANGE ) # update memory model name_ptr = self . current record_len = self . _record_size ( name , dimensions ) array_bytes = self . _buffer_size ( name , dimensions ) array_ptr = name_ptr + record_len total_bytes = record_len + array_bytes self . _memory . check_free ( total_bytes , error . OUT_OF_MEMORY ) self . current += total_bytes self . _array_memory [ name ] = ( name_ptr , array_ptr ) self . _buffers [ name ] = bytearray ( array_bytes ) self . _dims [ name ] = dimensions