]>
Commit | Line | Data |
---|---|---|
513c3efc SC |
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 | |
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 : "M8.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 | ||
0ddda300 | 45 | tell application "Finder" to set theXmlList to (every file of inFolder whose name ends with gXmlSuffix) |
513c3efc | 46 | |
0ddda300 DS |
47 | repeat with theXml in theXmlList |
48 | set theXml to theXml as string | |
513c3efc SC |
49 | set theXmlCount to theXmlCount + 1 |
50 | ||
51 | -- save the current text delimiters | |
52 | set theDelimiters to my text item delimiters | |
53 | ||
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" | |
59 | ||
60 | -- restore the text delimiters | |
61 | set my text item delimiters to theDelimiters | |
62 | ||
63 | tell application "CodeWarrior IDE" | |
64 | -- | |
65 | -- Import the selected xml file | |
66 | -- | |
67 | try | |
68 | make new project document as theImport with data theXml | |
69 | set theXmlSuccessCount to theXmlSuccessCount + 1 | |
70 | -- | |
71 | -- Close the project | |
72 | -- | |
73 | Close Project | |
74 | on error number errnum | |
75 | tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport | |
76 | end try | |
77 | end tell | |
0ddda300 | 78 | end repeat |
513c3efc SC |
79 | |
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) | |
83 | end repeat | |
84 | ||
85 | end ImportProjects |