First, an explanation of how ranks and titles work. There are two functions:
'SetRank(ref char, int iNation, int newrank)', defined in "PROGRAM\Characters\CharacterUtilite.c", sets the character's actual rank for that nation. Ranks are defined in "PROGRAM\NATIONS\nations_init.c" and copied in "RESOURCE\INI\TEXTS\ENGLISH\common.ini". That is used when you are promoted by talking to a governor, and it can also be used to set an NPC to a particular rank - for example, in "PROGRAM\Characters\init\SideQuest.c", it's used for "Sir Rodney Leighton" to set his rank to 8, Rear Admiral.
"SetRankTitle" is normally used to add a prefix such as "Sir". As you saw, it's used in "NK.c" when you are knighted, and it's also used on "Sir Rodney Leighton" to make him a "Sir". Exactly what that does to a character's name depends on whether the character is a naval officer or not. If he is, the rank goes before the prefix. Play the "Hornblower" storyline and listen to the video in which Captain Pellew introduces himself - or just watch the video directly using something like VLC on "RESOURCE\VIDEOS\Hornblower\Declaration of War.wmv":
Edward Pellew said:
My name is Captain Sir Edward Pellew and I'm here to tell you that your days of idling are over!
It also depends on which version of the character's name is being used. There are several functions in "PROGRAM\Dialog_func.c" to show a character's name with varying levels of formality, ranging from 'GetMySimpleName' which just gives the basic name, up to 'GetMyFullName' which shows the whole lot.
Being given the title "Sir" at level 7 was already in "NK.c". I expanded it a bit, including the title "Lord" for England at level 10, equivalents to "Sir" for other nations at level 7, and some tweaking of "Dialog_func.c" to display titles and ranks correctly. See this thread for more details:
Needs Testing - Nobs and Nobility
As for your officer Edward Pellew, you've used 'SetRank(ch, ENGLAND, 5)' to make him a Commander, then used 'SetRankTitle(ch, TranslateString("", "Chief Warrant Officer"))' to give him the prefix "Chief Warrant Officer". Warrant officers are either non-commissioned officers or very junior officers, and a rank 5 Commander is neither. In any case, as you've found, it doesn't work for your purpose. 'GetMyFullName' would call him "Commander Chief Warrant Officer Edward Pellew". 'GetMySimpleName', which appears to be used for the character's name in the interface screen, will simply call him "Edward Pellew". And his rank at the top of the screeen will display his real rank, which is "Commander".
As for Groves, that 'SetRankTitle(PChar, TranslateString("", "Commander"))' will have an interesting effect. As you've seen, it does nothing to his interface screen. But 'GetMyFullName' will show him as "Lieutenant Commander Theodore Groves". And Lieutenant Commander is a Lieutenant in command of a small ship, though according to
Wikipedia, the Royal Navy only adopted the term in 1914, rather too late for our purposes! I'll probably remove that line from "NK.c", and Lieutenant Groves can earn his promotions to Commander the same way as any other Lieutenant.