]> git.saurik.com Git - wxWidgets.git/blob - docs/mac/M5xml2mcp.applescript
Compile fix.
[wxWidgets.git] / docs / mac / M5xml2mcp.applescript
1 -----------------------------------------------------------------------------
2 -- Name: docs/mac/M5xml2mcp.applescript
3 -- Purpose: Automatic import of CodeWarrior 5 xml files to projects
4 -- Author: Gilles Depeyrot
5 -- Modified by:
6 -- Created: 30.11.2001
7 -- RCS-ID: $Id$
8 -- Copyright: (c) 2001 Gilles Depeyrot
9 -- Licence: wxWindows licence
10 -----------------------------------------------------------------------------
11 --
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.
15 --
16
17 --
18 -- Suffix used to recognize CodeWarrior xml files
19 --
20 property gXmlSuffix : "M5.xml"
21
22 --
23 -- Project and build success count
24 --
25 set theXmlCount to 0
26 set theXmlSuccessCount to 0
27
28 --
29 -- Ask the user to select the wxWindows samples folder
30 --
31 set theFolder to choose folder with prompt "Select the wxWindows folder"
32
33 ImportProjects(theFolder)
34
35 tell me to display dialog "Imported " & theXmlSuccessCount & " xml files out of " & theXmlCount buttons {"OK"}
36
37 --
38 -- ImportProjects
39 --
40 on ImportProjects(inFolder)
41 global theXmlCount, theXmlSuccessCount
42
43 tell application "Finder" to update inFolder
44
45 try
46 tell application "Finder" to set theXml to ((the first file of inFolder whose name ends with gXmlSuffix) as string)
47 on error
48 set theXml to ""
49 end try
50
51 if theXml is not "" then
52 set theXmlCount to theXmlCount + 1
53
54 -- save the current text delimiters
55 set theDelimiters to my text item delimiters
56
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"
62
63 -- restore the text delimiters
64 set my text item delimiters to theDelimiters
65
66 tell application "CodeWarrior IDE 4.0.4"
67 --
68 -- Import the selected xml file
69 --
70 try
71 make new project document as theImport with data theXml
72 set theXmlSuccessCount to theXmlSuccessCount + 1
73 --
74 -- Close the project
75 --
76 Close Project
77 on error number errnum
78 tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
79 end try
80 end tell
81 end if
82
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)
86 end repeat
87
88 end ImportProjects