  | | | optionVar string arrays? | optionVar string arrays? 2003-11-29 - By Bryan Ewert
Back ? from Fri, 28 Nov 2003 21:28:21 -0500
> However, it doesn't look like the optionVar arrays can be indexed. > > I can append to an array, > but I can't set or read the n-th item of an array.
You are correct; access to array optionVars is a bit limited.
To access the n'th item in an optionVar:
int $byIndex = 3; string $indexed = "";
string $vars[] = `optionVar -q stringArrayOptionVar`; if ( ( $byIndex >= 0 ) && ( $byIndex < `size $vars` ) ) { $indexed = $vars[$byIndex]; }
To set the n'th item requires rebuilding the optionVar:
string $vars[] = `optionVar -q stringArrayOptionVar`;
if ( ( $byIndex >= 0 ) && ( $byIndex < `size $vars` ) ) { $vars[$byIndex] = "value"; }
optionVar -clearArray stringArrayOptionVar; // <or> optionVar -remove stringArrayOptionVar;
for ( $item in $vars ) { optionVar -sva stringArrayOptionVar $item; }
-- Bryan Ewert ? maya@(protected) ? http://www.ewertb.com ?
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --- List-help: <mailto:listar@(protected)?Subject=help> List-archive: <http://www.highend3d.com/maya/devarchive/>
|
|
 |