We use @NoteId in a view to get the NoteId of a document and display the value in a column. Via NotesNavigator, we access this column ( and others ) Unfortunately, the value, that is returned by the formula is something like NT0000903.
When we pass this value to our function, to open the document in a tabContainer, it fails because the function excepts only the number part wthout the NT and leading zeros. ( = 903 ). So I was looking for a way to stip the unwanted part from the string.
Here is, what I came out with
tmp:=@ReplaceSubstring(@NoteID;"NT";"");
@Do(tmp := tmp;@While(@Length(tmp) > 1 & @Begins(tmp; "0");tmp := @Middle(tmp; 1; 8));tmp) ;
If there is a better solution, let me know. We tried many things, but to go thru the value from left to right and checking, if the string begins with a “0” seems to be the best way to achieve the aim.
Have you tried this one?
@RightBack(@NoteID;”0″)
Of course, but when you have a NoteId with NT0001022, it will return 22 instead of 1022
Oh, my fault. But this should work as required:
@Text(@TextToNumber(@RightBack(“NT0001022″;”NT”)));
Nope 🙂 because the NoteId can be NT00001AE and a TextToNumber will return 1 and not 1AE
Sorry Sven, that one fails too. A Note ID is hexadecimal.
What about this?
@Implode(@Trim(@Explode(@RightBack(“NT00101AE”;”NT”);”0″));”0″)
Cool, it works
Upps, sorry Sven, when the last number in the ID is 0, then this 0 is also stripped.
Three shots, three missed… I am giving up!
I just cheat. @ReplaceSubstring(@NoteID; “NT00000″:”NT0000″:”NT000″:”NT00″:”NT0”; “”)
🙂 🙂 Yes, we had this also, but found it not to be … profesional …
Who cares if it’s not professional… so long as it works and processes faster than a while loop. 🙂
Similar solution only with @for. In case you have a “high” NoteId, it might be faster I guess 🙂
_Tmp:=@ReplaceSubstring(@NoteID;”NT”;””);
_Len := @length(_tmp);
@For(x := 0 ; x =< _len ; x:=x+1;
@If(@Middle(_tmp;x;1) “0”;
@Do(
@Set(“_Tmp”;@Right(_tmp;_len-x));
x := _Len
)
;””)
);
_Tmp
Since you said you have to use it in a view, you can’t use @return, Otherwise the @do / @set could be replaced with a @return
hmmm when re-reading just noticed that the @set can be replace with just _tmp := as well 🙂
What do you think about this solution:
_NoneNT:= @Right (“NT001001AE”; 8);
_NoneZero:= @Trim(@ReplaceSubstring(_NoneNT; “0”; “”));
@Left(_NoneZero; 1) + @Right (_NoneNT; @Left(_NoneZero; 1));
Ups, @Trim is not necessary
_NoneNT:= @Right (“NT001001AE”; 8);
_NoneZero:= @ReplaceSubstring(_NoneNT; “0”; “”);
@Left(_NoneZero; 1) + @Right (_NoneNT; @Left(_NoneZero; 1));
Cool, Thx Andre