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:
This allows you to get the name of an existing in the project file.
ICodeWarriorDesign.Name Arguments:
This allows you to get the project associated with a design.
ICodeWarriorProject** pval - the project name.
This allows you to get the collection of targets associated with a design.
ICodeWarriorTargetCollection** pval - the target collection.
This allows you to get the container of symbols associated with a design.
ICodeWarriorSymbolContainer** pval - the symbols container.
This allows you to add a file to a design.
ICodeWarriorDesign.AddFile Arguments:
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.
Argument
Functionality
IFileSpec* FileSpec
ICodeWarriorDesign.AddFileByFileSpec Arguments:
ICodeWarriorProjectFile** projectFile - the project file data structure that the file was added to.
This allows you to find a file and add it to the design.
ICodeWarriorDesign.FindAndAddFile Arguments:
ICodeWarriorProjectFile** projectFile - the project file data structure that the file was added to.
This allows you to remove a target from the design.
Argument
Functionality
ICodeWarriorTarget* Targer
ICodeWarriorDesign.RemoveTargetFromDesign Arguments:
This allows you to compile files.
Argument
Functionality
ICodeWarriorProjectFileCollection* collection
ICodeWarriorDesign.CompileFiles Arguments:
long* cookie - a magical parameter whose purpose is not known at the time of this writing.
' 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