Great and I hope I wasn’t suggesting the first suggested solution wouldn’t work—which of course it does.
While, I’m waiting for a call to start I extended things a bit with 2 functions. The first replicates the earlier stamp, but using a function. In the second, a more generic method, we pass a numeric offset (e.g. a sibling +4 from us. Here are the functions:
function getOffsetDomain(iOffset:number){
var:string vPath;
var:number vOffset;
vOffset = $SiblingOrder + iOffset;
vPath = collect_if(siblings,$SiblingOrder==vOffset,$Path);
$MyString = $Path(vPath);
$MyString2 = $Domain(vPath);
} // END
function giveOffsetSiblingPath(iOffset:number){
var:string vPath;
var:number vOffset;
vOffset = $SiblingOrder + iOffset;
vPath = collect_if(siblings,$SiblingOrder==vOffset,$Path);
return vPath;
} // END
Extra stamps are provided to test each function. Note that you can’t use a function call as a direct offset value, i.e.:
$MyString2 = $Domain(giveOffsetSiblingPath(4)); // FAILS - do not use
In that case we need to capture the function output in a variable:
var:string vPath = giveOffsetSiblingPath(4);
$MyString2 = $Domain(vPath);
I also added a stamp that uses a negative (-2) offset, i.e. for a sibling 2 places lower (i.e. before the current) in the sibling order.
For @Gernot 's original problem, this is unneeded complication. But for later readers, I though it provides a nice example of taking a fixed pattern and making it into a variable one.
Note: this is a simple demo. i’m not doing things like checking if a note exists at the desired offset and just relying on the defaults working in my favour (i.e. an unset empty string remains empty). For real work one might consider safe-guards , e.g. some enclosing conditional test. But, I hope you get the general point about how we can work out sibling offsets.
Indeed, consider a scenario where for whatever reason the desired distance of offset is it self a variable - the outcome of some other calculation. That variable can be passed into the function instead of a literal number.
Here’s the updated TBX: sibling-offset-ref2.tbx (319.3 KB). There is no ‘read me’ - this post is it!