Hello all,
I have following goal: I have to come from:
- DK2632.AS03.CGenP.Hybrid.Twr1.TIn
to:
- B'CGenP'Twr1'Tin
where the first string is the full-branch of an template-instance and the second one is a BACnet keyname.
In fact I want to seperate the communication-elements out of the Fullbranch or the FullName by using e.g. a prefix or parameters.
Does anybody has an idea?
Thank you in advance
what about strreplace to replace . by '?
And you can use strright to take element on right of DK2632.AS03
And an even better solution.
string StrExtract(string String, char separatorChar, int Pos)
Returns a string that contains the substring of string parameter at the given zero based position (Pos) in string parameter that is delimited by one of the characters (separatorChars)
For example, if the current string is " My.name.is.John ", separatorChar is “.” and Pos is 1, the StrExtract method returns " name ".
Then the expression should work (I didn't try)
"B'" + StrExtract(Me.FullBranch,".",2) + "'" + StrExtract(Me.FullBranch,".",4)+ "'" + StrExtract(Me.FullBranch,".",5)
Read KB680 for further details, it's a goldmine 😉
Another solution, depending on how your templates are instanciated
"B'" + Me.TemplateInstance.Parent.Parent.Parent.Branch + "'" + Me.TemplateInstance.Parent.Branch + "'" + Me.TemplateInstance.Branch
or something like that...
Thank you all for your suggestions.
But they do not fit the goal. Now I think, that it is not really possible to solve it. The problem is, that the length of the branch can vary. so the communication objects can be everythere in the branch. I can not work with fixed indexes.
I would need something like a loop throught the single branches and check branch by branch, whether the node-type is an comm-object or a nav-object and use only the commobjects to build the communication-string.
something like:
e.g. for(i=0;i<=StrExcract(me.fullbranch).length,i++) {if(StrExcract(me.fullbranch,i).type == comm) then addToComString()};
But we don´t have loops :silly: 😆 :angry:
So I made another solution:
now I have a fix navigation part with a fixed length in the fullbranch, following by the communication part with a variable length. So I am able to remove the the nav-part in an expression.
the problem is, that I have now often redundant templates to build, because I have to rebuild the comm-part for every navigation - node. But it works now.
Again thank you.
Hi Johannes
I dont understand as the last solution given by Florent looked good and worked whatever the length of branch!
Nico


