Thanks all for the help - everything worked as intended.  The index I was using to get into the arrays was (unbeknownst to me at the time) 1-based instead of 0-based, so things weren't coming back as intended.  It all works now though - thanks!
-----Original Message-----
From: Patrick Niemeyer []
Sent: Tuesday, July 19, 2005 11:31 PM
To: Steele, Josh
Subject: Re: [Beanshell-users] arrays and the interpreter

On Jul 19, 2005, at 1:57 PM, Steele, Josh wrote:

I'm trying to initialize an array using something like this

Offset = new int[]{A,B,C}

where A, B, C have already been set in the interpreter instance. I seem to be able to eval the above statement fine, but I can't seem to find a way to get the array back out from the interpreter - get() only returns Objects, not arrays.  Also, when I try to get Offset[0], it returns null, even though I know A has been set to a value.

Is there something I'm missing?  Can bean

You should be able to do one of two things:

either get the whole array (which is itself an Object)

  int [] myArray = (int [])interpreter.get( Offset );

or eval() the index operation:

  Integer element0 = (Integer)interpreter.eval( "Offset[0]" );