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


ICodeWarriorAccessPathCollection

This collection is just like any other collection. Refer to "A Word About Collections" to learn more about working with collections. You can call the Count, Item, Add, and Remove methods as you would expect with any other collection.


Example Usage

An example script that illustrates many of the operations you can perform with access paths is shown here in Listing 3.3.

Access Paths Example:


' Jim Trudeau
' This script creates an application object, gets the default
' project, and gets the current target of that project.  It then
' creates a path for that target, adds it to system paths, and
' displays information about all system and user paths

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 target			'current target
	dim allPaths		'all access paths
	dim pathList		'collection of system or user paths
	dim path			'an individual path

	'get the current target
	set target = project.GetCurrentTarget
	
	
	textEngine.InsertText("Path Information" &eol)
	textEngine.InsertText("~~~~~~~~~~~~~~~~" &eol)

	'*** get all access paths
	set allPaths = target.AccessPaths
	
	'*** get the file spec for compiler folder
	set path = CW.FindLogicalFolder("Compiler")

	'*** create the path string to the MSL folder
	path.fullpath = path.fullpath &"\MSL\MSL_C"

	'*** create an access path (2 = compiler relative, 1 = system path)
	set path = allPaths.CreateAccessPath(path.fullpath, false, 2, 1)
	
	'*** add the path to target
	allPaths.ApplyChanges
	
	textEngine.InsertText("System paths are:" &eol)

	'*** get the system path list
	set pathList = allPaths.SystemAccessPaths

	DisplayPathInfo (pathList)

	textEngine.InsertText("User paths are:" &eol)

	'*** get the user path list
	set pathList = allPaths.UserAccessPaths

	DisplayPathInfo(pathList)
	
end if


'=========================================================
' DisplayPathInfo - display info on all paths in list
' receives the path list
'=========================================================

sub DisplayPathInfo (pathList)

	dim result			'returned values
	dim string			'array of strings	
	dim path			'an individual path
	dim index			'loop counter
	
	string = Array("Absolute","Project Relative","Compiler Relative", "System Relative","User Defined")

	'walk the path list
	for index = 0 to pathList.Count - 1
		
		'*** get the individual path object
		set path = pathList.Item(index)
	
		'*** get the actual path
		result = path.Path.FullPath
		textEngine.InsertText("  Path: " &result &eol)
	
		'*** get the recursion state
		result = path.Recursive
		textEngine.InsertText("  Recursive: " &result &eol)
	
		'*** get the path origin
		result = path.AccessPathLocation
		textEngine.InsertText("  Origin: " &string(result) &eol)
	
	next
	
	'skip a line between paths
	textEngine.InsertText(eol)

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