CodeWarrior scripts
CodeWarrior scripts
- Subject: CodeWarrior scripts
- From: Oleg Lodygensky <email@hidden>
- Date: Fri, 24 Aug 2001 16:42:05 +0200
Hi,
has anybody ever try to script CodeWarrior?
that's what I'm doing now; step by step CW script library grows but there's
two things that I just can't understand:
* It's ez to access SourceTree from preferences, but how can I access to
target Source Tree?
* I just can't figure out how to use "add" command, it says alias <my
alias> don't understand add. I have tried to use it with references to
project or to target, but it's all the same. Command 'add files' works fine
but it can't stores files to a group inside my project.
Any idea?
Here's my little codewarrior 'library'; may it help some of u...
/////////////////////////////////////////////////// start of file
-- Purpose: helps to manage CodeWarrior environment
-- ************************************************************
on addUserPath(newName, newRecursive, newFormat, newOrigine, newRoot,
newFlags)
-- newName : string -- The actual path name.
-- newFormat : Generic Path/MacOS Path/Windows Path/Unix Path -- Format
of the a
-- newOrigin : absolute/project relative/shell relative/system
relative/root relative
-- newRoot : string. Name of the root of the relative path. Pre-defined
values are 3Absolute2, 3Project2, 3CodeWarrior2, and 3System2. Anything
else is a user-defined root.
-- newRecursive : boolean -- Will the path be searched recursively?
(Default is true)
-- newFlags : integer -- Bit fields enabling the access path for each
host OS (1 = Mac OS, 2 = Windows)
-- ************************************************************
tell application "CodeWarrior IDE"
set thePath to {{name:newName, recursive:newRecursive,
format:newFormat, origin:newOrigine, root:newRoot, host flags:newFlag}}
set theAccessPaths to Get Preferences from panel "access paths"
set userpaths to (User Paths of theAccessPaths)
set userpaths to userpaths & thePath
set User Paths of theAccessPaths to userpaths
Set Preferences of panel "access paths" to theAccessPaths
end tell
end addUserPath
-- ************************************************************
on addSystemPath(newName, newRecursive, newFormat, newOrigine, newRoot,
newFlags)
-- cf addUserPath ()
-- ************************************************************
tell application "CodeWarrior IDE"
set thePath to {{name:newName, recursive:newRecursive,
format:newFormat, origin:newOrigine, root:newRoot, host flags:newFlag}}
set theAccessPaths to Get Preferences from panel "access paths"
set systempaths to (System Paths of theAccessPaths)
set systempaths to systempaths & thePath
set System Paths of theAccessPaths to systempaths
Set Preferences of panel "access paths" to theAccessPaths
end tell
end addSystemPath
-- ************************************************************
on checkSourceTree(sourceName)
-- Purpose : checks whether a Source Tree entry is already defined in
the global preferences (menu edit, item Preferences..)
-- Returns: true if source tree is already defined, false otherwise
-- sourceName : string -- name of the user-defined source tree root
-- ************************************************************
tell application "CodeWarrior IDE"
set theCurrentSourceTrees to Get Preferences from panel "Source
Trees"
set theCurrentTrees to Source Trees of theCurrentSourceTrees
repeat with currentTree in theCurrentTrees
if (name of currentTree = sourceName) then
return true
end if
end repeat
return false
end tell
end checkSourceTree
-- ************************************************************
on getSourceTree(sourceName)
-- Purpose : finds a Source Tree entry (menu edit, item Preferences..)
-- Returns: SourceTree value as string
-- Errors : an error is generated if source tree not found
-- How to use :
-- try
-- getSourceTree( myName )
-- on error errText number errNumber
-- display dialog errText & " " & errNumber as string
-- end try
-- sourceName : string -- name of the source tree
-- ************************************************************
tell application "CodeWarrior IDE"
set theCurrentSourceTrees to Get Preferences from panel "Source
Trees"
set theCurrentTrees to Source Trees of theCurrentSourceTrees
repeat with currentTree in theCurrentTrees
if (name of currentTree = sourceName) then
return currentTree
end if
end repeat
error sourceName & " is not a defined source tree " number 1
end tell
end getSourceTree
-- ************************************************************
on getSourceTreePath(sourceName)
-- Purpose : see getSourceTree() above
-- Params : see getSourceTree() above
-- Returns: SourceTree path as string
-- Errors : see getSourceTree() above
-- ************************************************************
tell application "CodeWarrior IDE"
set theSourceTree to getSourceTree(sourceName)
return path of theSourceTree as string
end tell
end getSourceTreePath
-- ************************************************************
on getSourceTreeKind(sourceName)
-- Purpose : see getSourceTree() above
-- Params : see getSourceTree() above
-- Returns: the SourceTree kind -- Absolute Path/Registry
Key/Environment Variable
-- Errors : see getSourceTree() above
-- ************************************************************
tell application "CodeWarrior IDE"
set theSourceTree to getSourceTree(sourceName)
return path kind of theSourceTree
end tell
end getSourceTreeKind
-- ************************************************************
on getSourceTreeFormat(sourceName)
-- Purpose : see getSourceTree() above
-- Params : see getSourceTree() above
-- Returns: SourceTree format -- Generic Path/MacOS Path/Windows
Path/Unix Path
-- Errors : see getSourceTree() above
-- ************************************************************
tell application "CodeWarrior IDE"
set theSourceTree to getSourceTree(sourceName)
return format of theSourceTree
end tell
end getSourceTreeFormat
-- ************************************************************
on addSourceTree(newName, newPath, newKind, newFormat)
-- Purpose : adds the given Source Tree from the global preferences
(menu edit, item Preferences..)
-- newName : string -- name of the user-defined source tree root
-- newPath : string -- path for the user-defined source tree root
-- newKind : Absolute Path/Registry Key/Environment Variable -- kind of
path
-- newFormat : Generic Path/MacOS Path/Windows Path/Unix Path -- Format
of the absolute path
-- ************************************************************
tell application "CodeWarrior IDE"
set theCurrentSourceTrees to Get Preferences from panel "Source
Trees"
set theCurrentTrees to Source Trees of theCurrentSourceTrees
set newsourcetree to {{name:newName, path:newPath, path
kind:newKind, format:newFormat}}
set theCurrentTrees to theCurrentTrees & newsourcetree
set Source Trees of theCurrentSourceTrees to theCurrentTrees
Set Preferences of panel "Source Trees" to theCurrentSourceTrees
end tell
end addSourceTree
-- ************************************************************
on deleteSourceTree(sourceName)
-- Purpose : removes the given Source Tree from the global preferences
(menu edit, item Preferences..)
-- Returns: true if source tree is already defined, false otherwise
-- sourceName : string -- name of the user-defined source tree root
-- ************************************************************
tell application "CodeWarrior IDE"
set currentSourceTrees to Get Preferences from panel "Source Trees"
set currentTrees to Source Trees of currentSourceTrees
set newTrees to {}
try
repeat with currentTree in currentTrees
if (name of currentTree is not equal to sourceName) then
set newTrees to newTrees & {currentTree}
end if
end repeat
end try
set Source Trees of currentSourceTrees to {}
Set Preferences of panel "Source Trees" to currentSourceTrees
set Source Trees of currentSourceTrees to newTrees
Set Preferences of panel "Source Trees" to currentSourceTrees
end tell
end deleteSourceTree
/////////////////////////////////////////////////// end of file