]> git.saurik.com Git - wxWidgets.git/blame - docs/mac/M5xml2mcp.applescript
added AppleScripts to export/import xml files from/to projects
[wxWidgets.git] / docs / mac / M5xml2mcp.applescript
CommitLineData
643b97f8
GD
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--
20property gXmlSuffix : "M5.xml"
21
22--
23-- Project and build success count
24--
25set theXmlCount to 0
26set theXmlSuccessCount to 0
27
28--
29-- Ask the user to select the wxWindows samples folder
30--
31set theFolder to choose folder with prompt "Select the wxWindows folder"
32
33ImportProjects(theFolder)
34
35tell me to display dialog "Imported " & theXmlSuccessCount & " xml files out of " & theXmlCount buttons {"OK"}
36
37--
38-- ImportProjects
39--
40on ImportProjects(inFolder)
41 global theXmlCount, theXmlSuccessCount
42
43 try
44 tell application "Finder" to set theXml to ((the first file of inFolder whose name ends with gXmlSuffix) as string)
45 on error
46 set theXml to ""
47 end try
48
49 if theXml is not "" then
50 set theXmlCount to theXmlCount + 1
51
52 -- save the current text delimiters
53 set theDelimiters to my text item delimiters
54
55 -- replace the ".xml" extension with ".mcp"
56 set my text item delimiters to "."
57 set theList to (every text item of theXml)
58 set theList to (items 1 thru -2 of theList)
59 set theImport to (theList as string) & ".mcp"
60
61 -- restore the text delimiters
62 set my text item delimiters to theDelimiters
63
64 tell application "CodeWarrior IDE 4.0.4"
65 --
66 -- Import the selected xml file
67 --
68 try
69 make new project document as theImport with data theXml
70 set theXmlSuccessCount to theXmlSuccessCount + 1
71 --
72 -- Close the project
73 --
74 Close Project
75 on error number errnum
76 tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
77 end try
78 end tell
79 end if
80
81 tell application "Finder" to set theSubFolders to every folder of inFolder
82 repeat with theFolder in theSubFolders
83 ImportProjects(theFolder)
84 end repeat
85
86end ImportProjects