If a Java object handle represents an instance of an array object, then it is also the name of a Tcl command that takes the following options: length, get, set, getrange, and setrange. If any other option is chosen, the behavior of the array object command defaults to that of the object command described above. The -noconvert flag can only be used with the get, getrange, and default options. The options for this command behave as follows:
set a [java::new {String[]} {6} {Java scripting is easy in Tcl}]
$a get 3
To retrieve a k-dimensional subarray of an n-dimensional array,
specifiy an indexList with n - k index values. For
example, the following commands result in subArray containing a
1-dimensional char array handle that refers to a[1][0], the internal
value of which is {e f}.
set a [java::new {char[][][]} {2 2 2} {{{a b} {c d}} {{e f} {g h}}}]
set subArray [$a get {1 0}]
set a [java::new {String[]} {6} {Tcl is a good scripting language!}]
$a set 3 great
set a [java::new {String[]} {6} {Java scripting is easy in Tcl}]
$a getrange 1 3
To retrieve a k-dimensional subarray
of an n-dimensional array, specifiy an indexList with n -
k index values. For example, the following commands result in
pair containing two 1-dimensional char array handles that refer
to a[0][1] and a[0][2], the internal values of which are {c d} and {e
f} respectively.
set a [java::new {char[][][]} {2 3 2} {{{a b} {c d} {e f}} {{g h} {i j} {k l}}}]
set pair [$a getrange {0 1} 2]
set a [java::new {String[]} {6} {Tcl is a good scripting language!}]
$a setrange 2 {an excellent}
The Conversions section describes the result and possible error conditions of the object command, including the effect of the optional -noconvert flag.
Copyright © 1997-1998 Sun Microsystems, Inc.