mb_get_array_index

Previous  Next

 

int mb_get_array_index( LPARRAY pArr, LPIXARRAY ix_array )

 


 

Returns the index into the array buffer using the supplied ix_array.  Use this for direct access to the array buffer.

 

Example

 

/////////////////////////////////////////////////////////////////////////////

// Simple class to attach a MyBASIC2 _array_t to the class and then set

// a value in the array

//

class CRealArray

  {

  public:

     CRealArray( LPARRAY pArray )

        {

        m_pArray pArray;

        }

     endfunc

 

     void Set( real_t* array, int ix, real_t rValue )

        {

        array[ix] = rValue;

        }

     endfunc

    

     void Set( int* ix_array, real_t rValue )

        {

        int ix = mb_get_array_index( m_pArray, ix_array );

        Set( m_pArray->raw, ix, rValue );

        }

     endfunc

 

  protected:

     LPARRAY      m_pArray;

  }

endclass