Thanks, the declaration syntax was what I particularly needed, got it working now.
Definitely options there that would be supportive of future complications (more commands, etc). > On Feb 1, 2017, at 05:36, Philippe Bergheaud <philippe.berghe...@fr.ibm.com> > wrote: > > > Modern ksh93 allows both what amounts to structures (typeset -T) and > > arrays (typeset -a or typeset -A). > > > > Is it possible to have an array of structures? (in particular, an > > associative array) > > > > If so, are there any examples available? > > > > Say that I have a structure consisting of at a minimum: > > > > vmhost > > vmstartcmd > > vmstopcmd > > > > and I want a structure with those members, and an array of them that > > can be looked up by vmname, given that I have VMs on multiple hosts > > using more than one sort of VM software (e.g. Parallels and VirtualBox). > > > I would simply create an associative array with > > $ typeset -A vm=( > [name1]=(host='host1'; start='start1'; stop='stop1') > [name2]=(host='host2'; start='start2'; stop='stop2') > ) > > The whole array could be printed in a reusable format with > > $ typeset -p vm > > Names (array indices) would be enumerated with > > $ print ${!vm[*]} # assuming no blanks in names > or > $ print "${!vm[@]}" # in the general case > > A name reference (a pointer) could be used to loop over the array entries > > $ for name in "${!vm[@]}" > > do > > typeset -n p=${vm[$name]} > > print "name=$name host=${p.host} start=${p.start} stop=${p.stop}" > > done > > Philippe
_______________________________________________ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users