Desalegn
(Desalegn)
June 3, 2018, 3:30pm
1
I was trying to assign a value to an attribute by searching inside the attribute of another note.
if($Father==""){$Father = (find ($Prototype=="Male"&$Begot.contains($GivenName(that))))};
This is assigning the name and path like Geo/John as a value for $Father attribute. I want only the name (removing the $Path) value.
How can I remove the path?
mwra
(Mark Anderson)
June 3, 2018, 4:34pm
2
As you’ve found find()
returns $Path which is a
/` delimited path of note names. So:
if($Father==""){
$MyString=find($Prototype=="Male"&$Begot.contains($GivenName(that)));
$Father = $MyString.split("/").at(-1);
$MyString=;
};
I’m using $MyString as when I tried using a var
$Father was the var name. Anyway, the above works for me.
Edit: Tinderbox seems to cope but there shouldn’t really be a space between find
and the parentheses holding its inputs).
mwra
(Mark Anderson)
June 3, 2018, 4:38pm
3
got it. this is cleaner if you don’t want to use an attribute as an in-loop value holder:
if($Father==""){
var X;
X=find($Prototype=="Male"&$Begot.contains($GivenName(that)));
$Father = X.split("/").at(-1);
};
Tested in b318.
1 Like
Desalegn
(Desalegn)
June 3, 2018, 10:37pm
4
Thank you.
This worked perfectly.
What does -1 stand for?
mwra
(Mark Anderson)
June 4, 2018, 7:12am
5
The last item in a list. See here for more.
1 Like
pat
(Pat Maddox)
June 6, 2018, 3:27pm
6
Perhaps collect_if
would come in useful here? It collects attributes from notes matching your query. It seems like you’re trying to get $Name
here, so you might try to get that directly:
$Father = collect_if(all, $Prototype=="Male" & $Begot.contains($GivenName(that)), $Name)
(I haven’t tested it, so it’s possible that the that
designator isn’t correct for collect_if
)
1 Like