[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


File Handling Events

You will want to use the File Handling Apple Events of the CodeWarrior IDE to do things like add and remove files in a project, close a window, create and close a project, and save copies of files.

Here are the events covered in this section:


Add Files

Purpose:

Adds the specified files to the current project.


Add Files filename-list [ to segment number ]

Description:

This event is equivalent to the Add Files command in the Project Menu. The filename-list parameter describes a single filename or list of filenames to add the current project. The optional to segment parameter specifies the segment in the project in which to add the files. Replace number with the segment number to place the files in. The default is to create a new segment.

Returns:

A list of errors. The result code for each file added to the project can either return the value of an OSErr (Operating System Error) or one of the following values:

Listing 0.5 Examples for Add Files


Add Files "MyFile.c"
Add Files "MyFile.c" to segment 2
Add Files {"MyFile.c", "MyFile2.c"}
Add Files {"MyFile.c", "MyFile2.c"} to segment 3


Close Project

Purpose:

Closes the current project.


Close Project

Returns:

None.


Close Window

Purpose:

Closes editor windows.


Close Window filename [ saving status ]

Description:

This event is equivalent to the Close command in the File Menu. If filename is a string, Close Window first tries to find the first matching window name, searching front to back. If no window name matches filename, then Close Window causes a search for a matching filename.

To specify read/only windows, add " [r/o 1]" to the end of filename.


Close Window "hello.c [r/o 1]"

Table A.2 lists file saving options used with the close window AppleScript command.

Table 0.2 Saving options (`savo')

 

Name
Property Code
yes (Save changes)  
'yes '  
no (Do not save changes)  
'no '  
ask (Ask the user whether to save)  
'ask '  

The optional saving parameter determines if the windows contents are saved before closing the window.

None.

Listing 0.6 Example for Close Window


Close Window "untitled" 
  -- Closes first "untitled" window.
Close Window "hello.c" saving yes
Close Window "main.c [r/o 1]" 
  -- Closes read/only window.


Create Project

Purpose:

Creates a new project file.


Create Project filename [ from stationery ]alias

Description:

Performs the New Project command in the File Menu. Replace filename with a single filename for the new project. If from stationery is specified, project stationery specified by alias is used to create the new project.

Returns:

The result code can have the following values:

Listing 0.7 Examples for Create Project


Create Project "HardDisk:Projects:MyProject.µ"
Create Project "Foobe" from ¬ 
 stationery "HD:Dev:Metrowerks" & ¬
 "CodeWarrior:(Project Stationery):MacOS:C/C++:" & ¬
 "Basic Toolbox 68k:Basic Toolbox 68k.mcp" 
Create Project "::sample project:sample.mcp"


Remove Files

Purpose:

Removes the specified file(s) from the current project.


Remove Files filename

Description:

Performs the equivalent of the Remove Selected Items command in the Project Menu. Replace filename with a single file or a list of files to remove from the current project.

Returns:

A list of errors. The result code can have one of the following values:

Listing 0.8 Examples for Remove Files


Remove Files "MyFile.c"
Remove Files { "MyFile.c", "YourFile.c" }


Save Error Window As

Purpose:

Saves the contents of the message window as a text file.


Save Error Window as filename

Description:

Performs the equivalent of the Save A Copy As command in the File Menu when the Message window is active. The contents of the Message window are saved with the name filename.

Returns:

None.

Listing 0.9 Example for Save Error Window As


Precompile "main.pch"
Save Error Window As "main.pch results"


Select

Purpose:

Selects an object from an open document in the CodeWarrior Editor.


Select reference

Description:

The parameter reference is the object to select.

Listing 0.10 Example for Select


Select text from character 5 to character 10 ¬
of line 8 of document 1


Set Modification Date

Purpose:

Sets the modification date of the specified file(s).


Set Modification Date filename-list to date

Returns:

A list of results of type short integer, or, if the ExternalEditor option is specified, a list of records of type 'ErrM'.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 02, 2000