[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: file type changer
- Subject: Re: file type changer
- From: rubywand@swbell.net
- Date: 1997/03/10
- Newsgroups: comp.sys.apple2
- Organization: Southwestern Bell Internet Services
- References: <5fvlic$3b7@news.ysu.edu>
Adalbert Goertz writes ...
>
> Can somebody tell me what file type changes are permissible?
> I can change TXT to BIN with no problem.
> I changed a BAS to SYS and my systej crashed when I ran teh SYS.
> I tried to change DNA to SYS16 and system crashed.
> So, what are the rules?
>
There are lots of rules. The basic rule is that a file's Type
is supposed to convey information about the file's format and/or
content. For example, a type $C1 file will be an unpacked super-res
screen image (displayed bytes, scanline control bytes, a few 'future
expansion' bytes, and bytes describing 16 palettes).
Since the Apple II world was quickly using up the 256 1-byte
Types, the 2-byte SubType (or "AuxType") was employed to
further specify Type. For instance, SubType lets a program decide if a
$C0 packed image file is in PaintWorks, Apple Preferred, etc. format.
The rationale for having Types is that it is information which is
easy to store in a disk's directory. Here, it can quickly be accessed
by a program to decide whether a particular file is the kind it can
use for input, the kind a user should be allowed to select, etc.. If
the program had to load-in and examine part of a file to make such
decisions, it would take much longer to get things done.
Programs like the File Manager NDA let you set a file's
1-byte Type and 2-byte SubType to whatever you wish. This
capability can be very helpful when a file's true Type has been lost,
say, in the process of downloading and/or transferring from another
machine. Setting the correct type will, often, decide whether or
not a file can be used as intended (e.g. as a packed picture).
Type is a label. Setting a file's Type does not change the
contents of the file. To actually function as a GSOS application, the
file has to be set up as a GSOS application. The same goes for an NDA,
ProDOS system file, and many other kinds of files. Sticking a "HORSE"
label on a dog does not make it a horse.
Binary files are different from others because there is no set
format for the content and no pre-set requirement or expectation for
what the content may or may not be. Given just the information that a
file is of Type "binary", a program's best expectation about content
is to have no expectations.
A Text file, too, may contain anything without breaking any
rules. However, it is generally expected that a Text file will contain
ASCII text; and, some programs will employ this assumption in deciding
how to deal with the file.
For GS programming, a good start on getting information about
file formats is to check out the sections on Object Module Format in
the GSOS Reference (p.441 ...) or ProDOS 16 Reference (p. 295 ...).
Sandy Mossberg did a nice piece on OMF in the November, 1988 issue of
Nibble (p. 94, ...).
To get info on writing NDA's, check the Toolbox Reference vol.1.
On page 5-6 of is a section titled "Writing New Desk Accessories".
Another source is The ByteWorks product: Toolbox Programming in C
(diskettes and _big_ manuals). It includes a lesson on New Desk
Accessories (p. 321 ...).
The easiest way to produce GSOS applications, NDA's, and other
goodies is to 'get into' a modern GS language system. ORCA/M,
ORCA/Pascal, and ORCA/C are some examples.
Rubywand