1 -----------------------------------------------------------------------------
2 -- Name: docs/mac/M5xml2mcp.applescript
3 -- Purpose: Automatic import of CodeWarrior 5 xml files to projects
4 -- Author: Gilles Depeyrot
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 : "M5.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
46 tell application "Finder" to set theXml to ((the first file of inFolder whose name ends with gXmlSuffix) as string)
51 if theXml is not "" then
52 set theXmlCount to theXmlCount + 1
54 -- save the current text delimiters
55 set theDelimiters to my text item delimiters
57 -- replace the ".xml" extension with ".mcp"
58 set my text item delimiters to "."
59 set theList to (every text item of theXml)
60 set theList to (items 1 thru -2 of theList)
61 set theImport to (theList as string) & ".mcp"
63 -- restore the text delimiters
64 set my text item delimiters to theDelimiters
66 tell application "CodeWarrior IDE 4.0.4"
68 -- Import the selected xml file
71 make new project document as theImport with data theXml
72 set theXmlSuccessCount to theXmlSuccessCount + 1
77 on error number errnum
78 tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
83 tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
84 repeat with theFolder in theSubFolders
85 ImportProjects(theFolder)