ResKnife — Template Editor

Supported template field types

As of version 0.6, ResKnife's template editor fully supports the following ResEdit field types:

DBYT, DWRD, DLNG
1‐, 2‐ and 4‐byte big‐endien signed integer.
FBYT, FWRD, FLNG
1‐, 2‐ and 4‐byte fillers.
CHAR
Single character. (MacRoman)
TNAM
Four character type code. (MacRoman)
PSTR, ESTR, OSTR, WSTR, LSTR
Pascal strings. (MacRoman)
CSTR, ECST, OCST
Null‐terminated C strings. (MacRoman)
OCNT, ZCNT
Counter for element lists (arrays).
LSTB, LSTC, LSTZ, LSTE
List begin, begin counted, and end.

In addition, there are about as many again Resorcerer‐only field types supported. Some further common field types are handled but displayed in an incorrect format (e.g. HWRD is displayed as DWRD). As the software develops these discrepencies will be eliminated. See below for a full enumeration.

In the end, we want to support at least all the field types Resorcerer supports. An exception may be made for field types that are deemed to be no longer interesting on MacOS X, and those types nobody is willing to implement.

Full list

The following tables provide a quick reference showing which resource edditors support white template field types. In the tables below the three editors represented are ResEdit (2.1.3), Resourcerer (2.0) and ResKnife (0.6) respectivly. A bullet denotes full support whereas an x indicates that a field type is recognised but not editable in its native format.

Decimal and Hex Integer Field Types
TypeDescriptionSizeEditors
DBYTSigned Decimal Byte1 byte
DWRDSigned Decimal Word2 bytes
DLNGSigned Decimal Long4 bytes
DLLGSigned Decimal Long Long8 bytes--
UBYTUnsigned Decimal Byte1 byte-
UWRDUnsigned Decimal Word2 bytes-
ULNGUnsigned Decimal Long4 bytes-
ULLGUnsigned Decimal Long Long8 bytes--
HBYTHex Byte1 bytex
HWRDHex Word2 bytesx
HLNGHex Long4 bytesx
HLLGHex Long Long8 bytes--x
Bit and Bit Field Types
TypeDescriptionSizeEditors
BBITBit Within a Byte1 bit-
BBnnBit Field Within a Bytenn bits-
WBITBit Within a Word1 bit--
WBnnBit Field Within a Wordnn bits--
LBITBit Within a Long1 bit--
LBnnBit Field Within a Longnn bits--
BFLGByte Boolean Flag (low-order bit)1 byte-x
WFLGWord Boolean Flag (low-order bit)2 bytes-x
LFLGLong Boolean Flag (low-order bit)4 bytes-x

Parsing proceeds from high-order bits first.

Miscellaneous Graphic and System Field Types
TypeDescriptionSizeEditors
RSIDSigned Resource ID Integer2 bytes-
BOOLBoolean Word *2 bytesx
CHARASCII Character1 byte
TNAMType Name4 bytes
DATEMacintosh System Date/Time (seconds)4 bytes-
MDATModification Date/Time (seconds)4 bytes-
LLDTLong Date/Time8 bytes--x
SCPCMacOS System Script Code2 bytes-x
LNGCMacOS System Language Code2 bytes-x
RGNCMacOS System Region Code2 bytes-x
STYLQuickDraw Font Style1 byte--x
PNT QuickDraw Point4 bytesx
RECTQuickDraw Rectangle8 bytesx
COLRQuickDraw Colour RGB Triplet6 bytes--
CLUTColour Lookup Table Hex Dumpvariable--
CODE680x0 Disassembled Code Dumpvariable--

* You can configure Resorcerer to use any 16-bit non-zero value when setting a BOOL field to true.

Floating and Fixed Point Field Types
TypeDescriptionSizeEditors
REALSingle Precision Float4 bytes-x
DOUBDouble Precision Float8 bytes-x
EXTNExtended 80-bit SANE Float10 bytes--
XT96Extended 96-bit SANE Float12 bytes--
UNIVTHINK C Universal 96-bit Float12 bytes--
FIXD16:16 Fixed Point Number4 bytes-
FRAC2:30 Fixed Point Fraction4 bytes-
SFRC0:16 Fixed Point Small Fraction2 bytes-x
FWID4:12 Fixed Point Font Width2 bytes-x
FXYZ1:15 Fixed Point Colour Component2 bytes-x
ASCII Text String Field Types
TypeDescriptionBytesEditors
PSTRPascal String1 ... 256
ESTREven-Padded Pascal String2 ... 256
PPSTEven Pascal String (pad included)2 .... 256--
OSTRPascal String Odd-Padded1 ... 255
CSTRNull-Terminated C String1 or more
ECSTEven-Padded C String2 or more
OCSTC String Odd-Padded1 or more
BSTRByte Length String (same as PSTR)1 ... 256-
WSTRWord Length String2 ... 65KB
LSTRLong Length String4 ... 4MB
TXTSSized Text Dumpvariable--
PnnnPascal String with Fixed Padding *$nnn bytes-
WnnnWord Pascal String with Fixed Padding$nnn bytes---
LnnnLong Pascal String with Fixed Padding$nnn bytes---
CnnnC String with Fixed Padding$nnn bytes-
TnnnText with Fixed Padding$nnn bytes--

* In Resorcerer, this field type's behavior is configurable between ResEdit-style and Resorcerer's own style.

Hexadecimal Dump Field Types
TypeDescriptionBytesEditors
BHEXByte Length Hex Dump1 ... 256--
WHEXWord Length Hex Dump2 ... 65KB--
LHEXLong Length Hex Dump4 ... 4MB--
BSHXByte Length - 1 Hex Dump1 ... 255--
WSHXWord Length - 2 Hex Dump2 ... 65KB-2--
LSHXLong Length - 4 Hex Dump4 ... 4MB-4--
HnnnFixed-Length Hex Dump$nnn-
HEXSSized Hex Dumpvariable--
HEXDHex Dump *variablex

* This field type's behavior is more general in Resorcerer than in ResEdit. Uneditable in ResKnife.

Skip Offset Field Types
TypeDescriptionSizeEditors
BSKPOffset to SKPE in Byte, inclusive1 byte--
WSKPOffset to SKPE in Word, inclusive2 bytes--
LSKPOffset to SKPE in Long, inclusive4 bytes--
BSIZOffset to SKPE in Byte, exclusive1 byte--
WSIZOffset to SKPE in Word, exclusive2 bytes--
LSIZOffset to SKPE in Long, exclusive4 bytes--
SKPEEnd of Skip or Sizeof0 bytes--

Automatically computed.

Symbolic Constants and Comments
TypeDescriptionSizeEditors
CASESymbolic and/or Default Value0 bytes-x
CMNTComment0 bytes--x
DVDRDivider Line with Optional Comment0 bytes-x
Counted Lists/Arrays
TypeDescriptionSizeEditors
OCNT(One-Based) Count of List Items2 bytes
ZCNTZero-Based Count of List Items2 bytes
BCNTByte Count of List Items1 byte-
BZCTZero-Based Byte Count of List Items1 byte--
WCNTWord Count of List Items (same as OCNT)2 bytes-
WZCTZero-Based Word Count of List Items (same as ZCNT)2 bytes--
LCNTLong Count of List Items4 bytes-
LZCTZero-Based Long Count of List Items4 bytes-
FCNTFixed Count of List Items0 bytes--
LSTCBegin Counted List Item0 bytes
LSTBBegin Non-Counted List Item0 bytes
LSTZBegin Non-Counted List Item, List Terminated by Zero Byte0 bytes
LSTSBegin Sized List Item0 bytes--
LSTEEnd of List Item0 or 1 bytes
SELFList Item is Entire TMPLvariable--
Key Values for Subsequent Variant Items
TypeDescriptionSizeEditors
KBYTSigned Decimal Byte Key1 byte-x
KWRDSigned Decimal Word Key2 bytes-x
KLNGSigned Decimal Long Key4 bytes-x
KLLGSigned Decimal Long Long Key8 bytes--x
KUBTUnsigned Decimal Byte Key1 byte-x
KUWDUnsigned Decimal Word Key2 bytes-x
KULGUnsigned Decimal Long Key4 bytes-x
KULLUnsigned Decimal Long Long Key8 bytes--x
KHBTHex Byte Key1 byte-x
KHWDHex Word Key2 bytes-x
KHLGHex Long Key4 bytes-x
KHLLHex Long Long Key8 bytes--x
KCHRSingle ASCII Character Key1 byte-x
KTYPFour-Character Type Key4 bytes-x
KRIDKey on Current Resource ID0 bytes-x
KIDXKey on List Index # (Zero-based)0 bytes--x
KEYBBegin Keyed Item for Previous CASE0 bytes--
KEYEEnd of Keyed Item0 bytes--
Alignment Field Types
TypeDescriptionBytesEditors
AWRDAlign to 2-byte boundary0 or 1-
ALNGAlign to 4-byte boundary0 ... 3-
AL08Align to 8-byte boundary0 ... 7--
AL16Align to 16-byte boundary0 ... 15--
AnnnAlign to byte boundary0 ... $nnn---

Uneditable.

Filler Field Types
TypeDescriptionSizeEditors
FBYTFill Byte1 byte
FWRDFill Word2 bytes
FLNGFill Long4 bytes
FnnnFill Bytes$nnn bytes--

Uneditable.

Inserting New Data Fields in Existing Resources
TypeDescriptionBytesEditors
+BYTInsert a Byte When Opening1--
+WRDInsert a Word When Opening2--
+LNGInsert a Long When Opening4--
+nnnInsert Bytes When Opening$nnn--
+PSTInsert a Pascal String When Opening1 ... 256--
+ESTInsert an Even Pascal String When Opening2 ... 256--
+CSTInsert a C String When Opening1 or more--
Deleting Old Data Fields from Existing Resources
TypeDescriptionBytesEditors
-BYTDelete a Byte When Closing1--
-WRDDelete a Word When Closing2--
-LNGDelete a Long When Closing4--
-nnnDelete Bytes When Closing$nnn--
-PSTDelete a Pascal String When Closing1 ... 256--
-ESTDelete an Even Pascal String When Closing2 ... 256--
-CSTDelete a C String When Closing1 or more--
Big and Little-Endian Parsing
TypeDescriptionSizeEditors
BNDNUse Big-Endian Data Parsing0--
LNDNUse Little-Endian Data Parsing0--
Pre- and Post-Processing Data with Code Filters
TypeDescriptionSizeEditors
FLTRDeclare Filtered Template (with comment)0--

Common Template Mistakes

Here's a list of simplifications or improvements one can make to existing templates.

  • Use correct type where available, e.g. RGNC for RegionCodes instead of a DWRD.
  • Use fillers (FWRD etc) for ‘Reserved’ values. Labels are optional.
  • PSTR followed by AWRD: Use ESTR instead.

© 2003 Uli Kusterer; © 2005–6 Nicholas Shanks. Some Rights Reserved.