Hi, I am a newbie to Rev, I am making a simple stack with some text fields displaying data. Some of they information in the fields in is in the wrong "sentence case". I have found a way to change this automatically using the property inspector of the field (i.e. in the property inspector - "Text Formatting" Tab - "Change Case" button at the bottom - then I can choose to have it in ALL CAPS, all lowercase, Sentence case, or Title Case (which I want)). I
My question is, is there any way of doing this in scripting? I am sure there must be, but through my searches of the dictionary I cannot find the right property name to do this. Can anyone help out? Thanks for any help.
Change Case
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Change Case
Useful functions are toUpper and toLower. To change the first character of a sentence in, for example, card field “test”, you could script:
To script title case, you could use:
This converts anything on line 1 to title case on line 2. It is coded this way for clarity- the “repeat” goes through originalTitle word by word, replacing the first character with its capital equivalent. We use this to build newTitle. newTitle will have an extra space on the end, which we remove.
Regards,
Michael
Code: Select all
put toUpper(char 1 of card field "test") into char 1 of card field "Test"
Code: Select all
put line 1 of card field "test" into originalTitle
repeat for each word w in originalTitle
put toUpper(char 1 of w) into char 1 of w
put w&space after newTitle
end repeat
delete the last char in newTitle
put newTitle into line 2 of card field "test"
Regards,
Michael