Unexpected action of TextStyleRemove function
I wanted to create a tagging system in my data-base, a selected word becomes highlighted or underlined. It works perfectly. However the problems appears when I want to delete highlighting or underline.
I have created a script to delete highlighting in the entire field:
Go to Field [Citations:Citation]
Insert Calculated Result [Select; Citations:Citation; TextStyleRemove(Middle(Citations:Citation; Get(ActiveSelectionStart);Get(ActiveSelectionSize));Underline]
The script works perfectly unless the first character of field Citation is underlined. Then instead of removing underline it actually does the opposite it underlines the whole field. Do You know what is the reason for that? I can send some printscreens or send a piece of code. I will be greatful for your help.