Topic: Title Case (1 of 4), Read 43 times
Conf: VEDIT Macro Language Support
From: Raymond Batson
Date: Friday, June 20, 2003 12:38 AM

Would like the ability to change the 1st letter in each word of a selected text field(s) to Caps Thanks

Example: From: now is the time for all good men to come to the aid of their party.
To: Now Is The Time For All Good Men To Come To The Aid Of Their Party.

Thanks

Ray Batson 817/303-1321 raybatson@...

 


Topic: Title Case (2 of 4), Read 39 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Friday, June 20, 2003 04:36 AM

> Would like the ability to change the 1st letter in each word of a selected text field(s) to Caps Thanks
>
> Example: From: now is the time for all good men to come to the aid of their party.
> To: Now Is The Time For All Good Men To Come To The Aid > >Of Their Party.

You could do this with a short macro. The basics would be (provided the text is marked as block):

GotoPos(Block_Begin)
Ins_Text(" ") //insert space to meet search specs
Char(-1)
BB(Cur_Pos)

Repeat(ALL){ //search separator+letter
Search_Block("|s|a",Block_Begin,Block_End,ERRBREAK)
Case_Upper_Block(Cur_Pos+1,Cur_Pos+2,NORESTORE) // convert
}

Fritz

 


Topic: Re: Title Case (3 of 4), Read 39 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Tuesday, July 01, 2003 02:53 PM

Here is a minor improvement to Fritz's macro:
(It does not insert an extra space.)

Goto_Pos(Block_Begin) //Goto beginning of block
if (At_BOL) { //If at begin-of-line...
// Handle first word in line
if ( Search_Block("|a",Block_Begin,Block_End,NOERR) ) {
Case_Upper_Block(Cur_Pos,Cur_Pos+1,NORESTORE)
}
} else { //Else, not at begin-of-line
Char(-1) //Backup before possible separator
BB(Cur_Pos)
}
//
// Loop to convert all (remaining) words in the block
//
Repeat(ALL){ //search separator+letter
Search_Block("|s|a",Block_Begin,Block_End,ERRBREAK)
Case_Upper_Block(Cur_Pos+1,Cur_Pos+2,NORESTORE) // convert
}

Thank you again Fritz for writing the macro.

Ted.

 


Topic: Re: Title Case (4 of 4), Read 39 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Tuesday, July 08, 2003 04:22 AM

Addendum: another interesting solution can be found on Scott Lambert's Vedit page:

http://carver.pinc.com/~slambert/charcase.vdm

Fritz