PilRC User's Manual (ver 1.0)

Wes Cherry (wesc@ricochet.net)
20 Oct 96

PilRC: A resource compiler for the US Robotics Pilot

PilRCUI: A GUI resource previewer

Usage

pilrc [-L LANGUAGE] infile [outdir]
pilrcui [-L LANGUAGE] infile

infile is a file describing the resources to be emitted. Each resource is written as a seperate file in the [outdir] directory. The output filename is constructed by appending the hexcode resource id to the four character resource type. For example, a FORM (tFRM) with formid of 15 would be written as tfrm000f.bin.

PilRCUI is a form previewer. It launches a window which previews a close approximation of forms as they would appear on the Pilot. Clicking in the content window of PilRCUI will cause it to reload the current script. Ideally PilRC and PilRCUI would be the same program, but I don't know how to create a program which conditionally runs in a console window or as a Win32 windows window. If anyone knows how to do this, let me know.

Syntax

PilRC's syntax is described below. Items in all CAPS appear as literals in the file. Items enclosed in < and > are required fields. The type is indicated by a suffix after the field name (see below for types). Items inclosed in [ and ] are optional fields.

Types

.i  = identifier
      example:  kFoo
.s  = string 
      example:  "Click Me"

.ss = multi line string.  PilRC will concatenate strings on seperate lines 
      enclosed with quotes and terminated by the \ character
      example:  "Now is the time for all good "\ 
                "men to come to the aid of their country"

.n = number, defined constant or simple arithmetic expression.  Valid operators are + - * /.  
      precedence is left to right. math is integer.
      examples: 23 12+3+1 12*4 14*3+5/2

.p = position coordinate.  Which may be either a number, expression or one 
     of the following keywords
        AUTO       : Automatic width or height.  The width/height of the 
                     item is computed based on the text in the item.  
	             valid only for widths or heights of items.
        CENTER     : Centers the item either horizontally or vertically.  
                     Only valid for left or top coordinate of an item.
	PREVLEFT   : Previous items left coordinate
	PREVRIGHT  : Previous items right coordinate
	PREVWIDTH  : Previous items width
	PREVTOP    : Previous items top coordinate
	PREVBOTTOM : Previous items bottom coordinate
	PREVHEIGHT : Previous items height
	
	example: PREVRIGHT+2 
	
	NOTE:  AUTO and CENTER must stand alone and are not valid in 
        arithmetic expressions

FORM (tFRM) syntax:

FORM ID <FormResourceId.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>)
[FRAME]
[NOFRAME]
[MODAL]
[SAVEBEHIND]
[USABLE]
[HELPID <HelpId.n>]
[DEFAULTBTNID <BtnId.n>]
[MENUID <MenuId.n>]
BEGIN
	<OBJECTS>
END

<OBJECTS>: one or more of:

TITLE <Title.s>
BUTTON <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT <FontId.n>]
PUSHBUTTON <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>] [GROUP <GroupId.n>]
CHECKBOX <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>] [GROUP <GroupId.n>] [CHECKED]
POPUPTRIGGER <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId.n>]
SELECTORTRIGGER <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId.n>]
REPEATBUTTON <Label.s> ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT <FontId.n>]
LABEL <Label.s> ID <Id.n> AT (<Left.p> <Top.p>)[USABLE] [NONUSABLE] [FONT <FontId.n>]
FIELD ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>)[USABLE] [NONUSABLE] [DISABLED] [LEFTALIGN] [RIGHTALIGN] [FONT <FontId.n>] [EDITABLE] [NONEDITABLE] [UNDERLINED] [SINGLELINE] [MULTIPLELINES] [MAXCHARS <MaxChars.n>]
POPUPLIST ID <Id.n> <IdList.n>
LIST <Item.s> <Item2.s>... ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABLE] [DISABLED] [VISIBLEITEMS <NumVisItems.n>] [FONT <FontId.n>]
FORMBITMAP AT (<Left.p> <Top.p>) [BITMAP <BitmapId.n> [NONUSABLE]
GADGET ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) [USABLE] [NONUSABE]
TABLE ID <Id.n> AT (<Left.p> <Top.p> <Width.p> <Height.p>) ROWS <NumRows.n> COLUMNS <NumCols.n> COLUMNWIDTHS <Col1Width.n> <Col2Width.n.>...
GRAFFITISTATEINDICATOR AT (<Left.p> <Top.p>)

Example: (this is a cliff notes version of AlarmHack's resource)

FORM ID 1 AT (2 2 156 156)
USABLE
MODAL
HELPID 1
MENUID 1
BEGIN
	TITLE "AlarmHack"
	LABEL "Repeat Datebook alarm sound" ID 2000) AT (CENTER 16) 
	PUSHBUTTON "1" ID 2001 AT (20 PrevBottom+2 12) AUTO GROUP 1
	PUSHBUTTON "2" ID 2002 AT (PrevRight+1  PrevTop PrevWidth PrevHeight) GROUP 1
	PUSHBUTTON "3" ID 2003 AT (PrevRight+1  PrevTop PrevWidth PrevHeight) GROUP 1

	LABEL "times.  Ring again every" ID 601 AT(CENTER PrevBottom+2) FONT 0

	PUSHBUTTON "never" ID 3000 AT (13 PrevBottom+2 32 12) GROUP 2
	PUSHBUTTON "10 sec" ID 3001 AT (PrevRight+1 PrevTop PrevWidth PrevHeight) GROUP 2
	PUSHBUTTON "30 sec" ID 3002 AT (PrevRight+1 PrevTop PrevWidth PrevHeight) GROUP 2
	PUSHBUTTON "1 min" ID 3003 AT (PrevRight+1 PrevTop PrevWidth PrevHeight) GROUP 2

	LABEL "Alarm sound:" ID 601 AT (24 PrevBottom+4)
	POPUPTRIGGER "          " ID 5000 AT (PrevRight+4 PrevTop 62 AUTO) LEFTANCHOR
	LIST "Standard" "Skip Along" "Beethoven" "EuroCop" "Cricket" "Bleep" "Computer2" ID 6000 AT (PrevLeft PrevTop 52 1) VISIBLEITEMS 10 NONUSABLE
	POPUPLIST ID 5000 6000

	BUTTON "Test" ID 1202 AT (CENTER 138 AUTO AUTO)
	GRAFFITISTATEINDICATOR  AT (100 100)
END

MENU (MBAR) syntax:

MENU ID <MenuResourceId>
BEGIN
	<PULLDOWNS>
END


<PULLDOWNS>: one or more of:

PULLDOWN <PulldownTitle.s>
BEGIN
	<MENUITEMS>
END

<MENUITEMS>: : one or more of:
	MENUITEM <MenuItem.s> <MenuItemId.n> [AccelChar.c]

Example:
MENU ID 100
BEGIN
	PULLDOWN "File"
	BEGIN
		MENUITEM "Open..." ID 100 "O"	
		MENUITEM "Close" ID 101 "C"
	END
	PULLDOWN "Options"
	BEGIN
		MENUITEM "Get Info..." ID 500 "I"
	END
END

ALERT (tALT) syntax:

ALERT ID <AlertResrouceId.n>
[HELPID <HelpId.n>]
[INFORMATION] [CONFIRMATION] [WARNING] [ERROR]
BEGIN
	TITLE <Title.s>
	MESSAGE <Message.ss>
	BUTTONS <Button.s> <BUTTON.s>...
END

Example:
ALERT ID 1000
HELPID 100
CONFIRMATION
BEGIN
	TITLE "AlarmHack"
	MESSAGE "Continuing will cause you 7 years of bad luck\n"\
		"Are you sure?"
	BUTTONS "Ok" "Cancel"
END

VERSION (tVER) syntax:

VERSION ID <VersionResourceId.n> <Version.s>

Example:
VERSION ID 1 "0.09"

STRING (tSTR) syntax:

STRING ID <StringResourceId.n> <String.ss>

Example:
STRING ID 100 "This is a very long string that demonstrates carriage retuns\n" \
	"as well as continued .ss syntax strings"

APPLICATIONICONNAME (tAIN) syntax:

APPLICATIONICONNAME ID <AINResourceId.n> <ApplicationName.s>

Example:
APPLICATIONICONNAME ID 100 "AlarmHack"

APPLICATION (APPL) syntax:

APPLICATION ID <ApplResourceId.n> <APPL.s> 

(APPL must be 4 chars)

Example:
APPLICATION ID 1 "ALHK"

International Support:

PilRC supports a limited form of international tokenization. It works by substituting strings in the resource definitions with replacements specified in a TRANSLATION section. Multiple translation blocks may be specified in a resource script. The active language is specified with the -L flag to PilRC. (Yeah, I know this is a pretty cheezy way to do this, but it has worked so far. The biggest problem is with positioning of controls. If you use AUTO, CENTER and PREVRIGHT et al it might not involve any position changing in your script. If you do need to change the position, right now the only workaround is to put some #ifdefs in your file and hook up a custom rule to preprocess your source file)

Example:
pilrc -L FRENCH myscript.rcp res

Translation syntax:

TRANSLATION <Language.s>
BEGIN
	<STRINGTRANSLATIONS>
END

where <STRINGTRANSLATINOS> is one or more of:
<Original.s> = <Translated.ss>

Example:
TRANSLATION "FRENCH"
BEGIN
	"Repeat Datebook alarm sound" = "Répétitions Alarme Agenda" 
	"Ring again every" = "Rappel tous les" 
END

TIP: For long strings define a short keyword and then define both native and foriegn translations for it.

Include Files

PilRC supports #include files with a limited syntax. Include files are specified by the #include directive: #include "includefile.h"

Include file syntax:

#define <Symbol.i>	<Value.n>
or 
<Symbol.i>	equ	<Value.n>

These defined constants may be used anywhere a constant is expected. Note that #ifdefs are ignored by PilRC.