Glossary Key:
wptr Refers to the pointer to a window record which contains all of the information about the window needed by the system.
This value is returned by a window specifier.
Definitions:
@MOUSEXY -- x\y
Returns coordinates of the mouse.
ADD.WINDOW
wptr--Opens a window on the screen using the preset title, bounds, behind, type and attributes. The content region is sized for the specified controls.
BS -- 8
A constant which returns the ASCII value of a backspace.
FRONT.WINDOW -- wptr
Returns the window pointer of the front window (which is the current ly active window).
GET.WINDOW -- wptr
Returns the window pOinter of the current window used for output.
MAC. CON -- addr
Returns the address of the Mac console device table. The phrase MAC.CON CONSOLE!
directs output to the Mac console.
MOUSE.DOWN -- n
Returns the value of a mouse down event (as returned by DO.EVENTS).
NEW.WINDOW «compile time»
PAGE
-- wptr «run time»
Defining word which creates text window specifiers. When the window specifier is later executed, its window pOinter is returned on the stack.
Clears the window and puts the cursor in the upper left corner.
Windows Page 8 - 10 June 4, 1984
SCREEN. BOUNDS -- addr
Returns the address of the rectangle containing the screen boundaries.
The rectangle coordinates are in packed 16-bit values for top, left, bottom, and right.
SYS.WINDOW -- addr
Default MacFORTH window name. This is the window presented when MacFORTH is active.
TYPE addr\cnt
--Outputs the specified string to the current window.
W.BEHIND front wptr\back wptr
--Causes the window specified as 'back wptr' to be opened behind 'front wptr.
W.BOUNDS x 1 \y 1 \x2\y2\wptr
--Sets the bounds of the window specified.
WTITLE
addr\wptr--Places the supplied string address into the window parameter list.
When the window is opened the title string is taken from the specified address.
W.TYPE
n\wptr--Sets the window type. The default is 0 (document windows).
WI NDOW
wptr--Sets the specified window as the window for output. All text and graphics images will be output to that window.
Windows Page 8 - 11 June 4,1984
Windows Page 8 - 12 June 4, 1984
Chapter 9: F i 1 e System
Overview 3
File I/O Operation Result Codes 3
File Assignment 4
File Numbers 4
Alternate Volumes 4
Displaying File Assignments 5
Opening a File 5
Displaying the Disk Directory 5
MacFORTH Fi le Types 6
Specifying Record Size 8
Accessing Records 8
Creating a Blocks File 11 Allocating Space ina Blocks File 12 Rea 11 ocat i ng Space
Within a Blocks Fi le 12 Accessing Program Source Code
in a Blocks Fi le 12
MacFORTH Blocks File Structure 13
Including a File 14
Advanced File System Topics IS Fi Ie Control Blocks 15
Fi Ie Pointer 15
Position Modes 15
File Names 16
Volume Names 16
Maximum File Length 16
Appendix A: Example File Usage 17 Appendix B: File System I/O Result
Codes 19
Appendix C: File System Glossary 20
File System
Page 9 - 2 June 4, 1984Overview
This chapter discusses how MacFORTH interfaces to the Macintosh file system. Using MacFORTH, you can create, read and write any standard Macintosh file. This allows you to share data among applications.
You can have up to 9 files assigned and open at a time for accessing the data within a file. MacFORTH supports two file types: data and program (or
"blocks") files. The records within a data file can be one of three types: fixed length records, text records and virtual data files (free-format records). The records within a program file are fixed length records, each containing 1024 characters.
We refer to program files as "b locks" files because they are made up of source code blocks (as explained in the Editor chapter).
File Input/Output Operation Result Codes
For each file operation a result code is returned in the variable IO-RESUl T.
This result code allows you to check the operation to see if it completed successfully, and if not, why not.
Each of the 1/0 result codes are listed in Appendix B of this chapter for your reference. If the file operation is successful, the result code is 0, otherwise the value indicates an error condition. This allows you to monitor the result of each file operation. You can then set the level of error checking from no checking to full error checking/re-try attempts, etc. I f you aren't concerned with the result of the operation, ignore it.
The word ?FllE.ERROR is provided to handle file manipulation error conditions in a basic manner. It is executed immediately following a file operation and, if an error occurred, will abort the current task displaying the appropriate error message. For example if you executed the phrase (don't try it now)
1 OPEH ?FILE.ERROR
and the file assigned to file number 1 was not found (1/0 result code -43), the current task would be aborted and the error message "File Not Found!" would be displayed.
File System Page 9 - 3
June 4, 1984FiJe Assignment
The Macintosh fi le system is based on assigning files (using their names) to a file number and using that number in referring to the file. In MacFORTH, we recommend that you use a CONSTANT value to refer to the file number to make your programs more readable.
File Numbers The first thing you must do when preparing to create a new file, or access an existing file, is assign 1t a file number. MacFORTH allows you to access up to 9 files using file numbers 0-8. If you use a file number outside of the range 0-8, MacFORTH will issue the error message "Illegal File#".
The command ASSIGN assigns a file number to a file name and is used in the following format:
<"file name"> <file-
(0-8»ASSIGN
For example, the phrase