Good luck. It's extremely difficult to parse MKS's output.
For instance the "si viewsandbox" command indicates subproject structure by indentation.
Here is a Perl code snippet to map members to subprojects:
our %parentproject;
our @projects;
my @subprojects;
$subprojects[0] = $sandbox;
$projects[0] = $sandbox;
open MKS, "si viewsandbox -R -S $sandbox |" or die $!;
while () {
chomp;
next if /working file/i;
next if /new revision available/i;
my ($indentation, $filename, $project, $version, $type);
if (m:^( +)$dir/(.+) archived (.+) *$:) {
($indentation, $filename, $version) = ($1, $2, $3);
}
if (m:^( +)$dir/(.+project) (\((.+)\) )?(.*subsandbox) *$:) {
($indentation, $project, $version, $type) = ($1, $2, $4, $5);
}
next unless $indentation;
my $level = length($indentation) / 2 + 1;
if ($project) {
$subprojects[$level] = $project;
$parentproject{$project} = $subprojects[$level - 1];
push @projects, $project;
}
if ($filename) {
$parentproject{$filename} = $subprojects[$level - 1];
}
}
This script runs on Linux, so folder separators are /. You may want to use \ in some regexps on Windows.
Please take time to appreciate the beauty of MKS' output. Direct members of the project
indented by 1. Members of a subproject indented by 3. Members of a subproject of a subproject indented by 5. And so on.
I'd give up, and write ad hoc scripts where absolutely necessary, but no more.
And yes, the output does change between versions. Sometimes.