1 -----------------------------------------------------------------------------
2 -- Name: docs/mac/M8xml2mcp.applescript
3 -- Purpose: Automatic import of CodeWarrior 8 xml files to projects
4 -- Author: Gilles Depeyrot
5 -- Modified by: Stefan Csomor
8 -- Copyright: (c) 2001 Gilles Depeyrot
9 -- Licence: wxWindows licence
10 -----------------------------------------------------------------------------
12 -- This AppleScript automatically recurses through the selected folder looking for
13 -- and importing CodeWarrior xml files to projects
14 -- To use this script, simply open it with the 'Script Editor' and run it.
18 -- Suffix used to recognize CodeWarrior xml files
20 property gXmlSuffix : "M8.xml"
23 -- Project and build success count
26 set theXmlSuccessCount to 0
29 -- Ask the user to select the wxWindows samples folder
31 set theFolder to choose folder with prompt "Select the wxWindows folder"
33 ImportProjects(theFolder)
35 tell me to display dialog "Imported " & theXmlSuccessCount & " xml files out of " & theXmlCount buttons {"OK"}
40 on ImportProjects(inFolder)
41 global theXmlCount, theXmlSuccessCount
43 tell application "Finder" to update inFolder
45 tell application "Finder" to set theXmlList to (every file of inFolder whose name ends with gXmlSuffix)
47 repeat with theXml in theXmlList
48 set theXml to theXml as string
49 set theXmlCount to theXmlCount + 1
51 -- save the current text delimiters
52 set theDelimiters to my text item delimiters
54 -- replace the ".xml" extension with ".mcp"
55 set my text item delimiters to "."
56 set theList to (every text item of theXml)
57 set theList to (items 1 thru -2 of theList)
58 set theImport to (theList as string) & ".mcp"
60 -- restore the text delimiters
61 set my text item delimiters to theDelimiters
63 tell application "CodeWarrior IDE"
65 -- Import the selected xml file
68 make new project document as theImport with data theXml
69 set theXmlSuccessCount to theXmlSuccessCount + 1
74 on error number errnum
75 tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
80 tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
81 repeat with theFolder in theSubFolders
82 ImportProjects(theFolder)