[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


ICodeWarriorDesign

This section discusses the ICodeWarriorDesign interface. You might use this interface to get or set names, get target info, or add and compile files.

You will also want to refer to "ICodeWarriorProject" as it contains helpful accompanying methods to use. For example, to retrieve a design you would use the Designs and FindDesign methods of ICodeWarriorProject. To remove a design you would use RemoveDesignByName and RemoveDesign. You would also create a new design using ICodeWarriorProject.

To see an example of how to use designs in your scripts, refer to Listing 3.18.

The topics in this section include:


Getting a Design's Name - Name

This allows you to get the name of an existing in the project file.


Return Value

BSTR* pval - the design name.


Setting a Design's Name - Name


Arguments

 

Argument
Functionality
BSTR pval  
The name to set for the design  

ICodeWarriorDesign.Name Arguments:

Return Value

None


Getting a Design's Project - Project

This allows you to get the project associated with a design.


Return Value

ICodeWarriorProject** pval - the project name.


Getting a Collection of Targets - Targets

This allows you to get the collection of targets associated with a design.


Return Value

ICodeWarriorTargetCollection** pval - the target collection.


Getting the Browser Symbols - BrowserDB

This allows you to get the container of symbols associated with a design.


Return Value

ICodeWarriorSymbolContainer** pval - the symbols container.


Adding a File to a Design - AddFile

This allows you to add a file to a design.


Arguments

 

Argument
Functionality
BSTR path  
The path to the file to add to the design  
BSTR groupPath  
The group to add the file to, an empty string is legal to pass here if you want to add to any group.  

ICodeWarriorDesign.AddFile Arguments:

Return Value

ICodeWarriorProjectFile** projectFile - the project file data structure that the file was added to.

Adding a File to a Design - AddFileByFileSpec

This allows you to add a file by file spec to the design.


Arguments

 

Argument
Functionality
IFileSpec* FileSpec  
The file spec for the file to add to the design  
BSTR groupPath  
The group to add the file to, an empty string is legal to pass here if you want to add to any group.  

ICodeWarriorDesign.AddFileByFileSpec Arguments:

Return Value

ICodeWarriorProjectFile** projectFile - the project file data structure that the file was added to.


Adding a File to a Design - FindAndAddFile

This allows you to find a file and add it to the design.


Arguments

 

Argument
Functionality
BSTR path  
The path for the file to check for in the design  
BSTR groupPath  
The group to add the file to, an empty string is legal to pass here if you want to add to any group.  

ICodeWarriorDesign.FindAndAddFile Arguments:

Return Value

ICodeWarriorProjectFile** projectFile - the project file data structure that the file was added to.


Removing a Target from a Design - RemoveTargetFromDesign

This allows you to remove a target from the design.


Arguments

 

Argument
Functionality
ICodeWarriorTarget* Targer  
The target to remove from the design  

ICodeWarriorDesign.RemoveTargetFromDesign Arguments:

Return Value

None


Compile Files - CompileFiles

This allows you to compile files.


Arguments

 

Argument
Functionality
ICodeWarriorProjectFileCollection* collection  
The collection for the files to compile  

ICodeWarriorDesign.CompileFiles Arguments:

Return Value

long* cookie - a magical parameter whose purpose is not known at the time of this writing.


Example Usage

Using Designs in a Script:


' file:    04 Designs.vbs
' author:  Jim Trudeau, Metrowerks
' created: August 23, 1999
' This script creates an application object and gets the default
' project. It then gets all designs in this project, displays the
' name of each design, gets the list of all targets that belong
' to the design, and lists each target name.

' To see this script work to best effect, a project that contains
' one or more designs must be the default project.


option explicit		'all variables must be declared

dim CW
dim project			'default project
dim textDocument	'text document object to hold report
dim textEngine		'the object for dealing with text
dim eol				'end-of-line character for formatting
dim result			'returned values

eol = chr(13)		'set end of line character

'create an instance of CodeWarrior
set CW = CreateObject("CodeWarrior.CodeWarriorApp")

'create text document and get engine
set textDocument = CW.OpenUntitledTextDocument()
set textEngine = textDocument.TextEngine

'get the default project
set project = CW.DefaultProject
	
'do some error control here
if TypeName(project) = "Nothing" then

	textEngine.InsertText("Script operates on default project." &eol)
	textEngine.InsertText("There must be at least one open project." &eol)	

else

	dim index			'loop counter
	dim designList		'design collection
	dim design			'individual design
	dim targetList		'target collection
	
	'*** get all designs for this project
	set designList = project.Designs
	
	'*** get the number of designs
	result = designList.Count
	textEngine.InsertText("Number of designs: " &result &eol)
	
	'walk through the designs
	for index = 0 to designList.Count-1
	
		'*** get a particular design
		set design = designList.Item(index)
	
		'*** get the design name
		result = design.Name
		textEngine.InsertText("Design: " &result &eol)
	
		'*** get the list of targets for this design
		set targetList = design.Targets
	
		'display each target's name
		ListTargets targetList
		
	next

end if

'=========================================================
' ListTargets - display name of each target in collection
' receives target collection interface
'=========================================================

sub ListTargets (targets)

	dim index
	dim target
	
	textEngine.InsertText("Targets:" &eol)

	for index = 0 to targets.Count-1
		set target = targets.Item(index)
		textEngine.InsertText(target.Name &eol)
	next
	
end sub


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 02, 2000