Revision as of 17:34, 27 June 2007 by Macoshark (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Codewarrior Scripting

From Nokia Developer Wiki
Jump to: navigation, search



CodeWarrior has a (poor) scripting API that can be used to add nifty little helper features that can make the everyday programming task a bit more easier.


All that needs to be done is to store the perl scripts to a folder somewhere and then adding a command binding in CodeWarrior to call the script. In each script I will give the binding that I use, but they can be bound to any key combination.

To Upper/Lower Case

This is a script that implements the conversion of selected text to upper or lowercase. This comes standard in Visual Studio, but is lacking from CodeWarrior.

File: upper_case.pl

use strict;
use warnings;
use Win32::OLE;
use POSIX;
# Create instance of CodeWarrior
my $CWApp = Win32::OLE->new("CodeWarrior.CodeWarriorApp");
# Get active document
my $doc = $CWApp->ActiveDocument() or die "can't get active doc!\n";
my $text_engine = $doc->TextEngine or die "can't get TextEngine!\n";
# Check that there is a selection
if( $text_engine->HasSelection() ) {
# Get selected text
my $selected_text = $text_engine->SelectionText();
my $param = uc $ARGV[0];
if ( $param eq "L" ) {
$selected_text = lc $selected_text;
} else {
$selected_text = uc $selected_text;
# Reset the selected line contents
$text_engine->InsertText( $selected_text );
154 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.