#!/usr/bin/macro
#First macro script.
# <-- comments :)

.define 				#this is where the macro definitions go, here
	1:file.variable 		#Will represent a file in the cwd.
	>pattern "*.bmp"		#Not sure if this will be wildcard or regex...
	2:repeat			#These are for repetitive motions.
	>text "\t\t\t\"${1}\" \\"	#This is the text which will be repeated. Macros are expanded, see footnote 1.
	>opts:resetvars			#each time this is expanded, the macros in the text portion will be reset to their first expansion.
	3:repeat
	>text "ICON ${4}\nBEGIN\n\tBITMAP \"${1,noinc}\" BPP 16 DENSITY 2 TRANSPARENT 255 0 255\n\tBITMAP \"${1,stripext}_s\" BPP 16 TRANSPARENT 255 0 255\nEND" #See footnote 2 for info on options.
	4:variable			#These are any interger variable....
	>initval:10000			#This is the value assigned at script load, or when a repeat is called with resetvars option.
	>computation:${4}+10->${4}	#This is the computation made BEFORE the variable is expanded. Only other variables are expanded within
define.

#This is just a standard PalmOS resource definition in PilRC format.
# pilrc.sf.net for info on pilrc incl. docs, and see 
# http://web.archive.org/web/20070816142916/www.estvo.com/developers/?specification for info on the skin specific format.
.text 
VERSION "1.0"
	
// Author
STRING ID 100 "My Name"

// Text info
STRING ID 200 "My first iconpack"

// Creator mapping table
// 'addr - 'Address Book, icon resource ID - 10000, 10001
// 'calc' - Calculator, icon resource ID - 10010, 10011
// 'memo' - MemoPad, icon resource ID - 10020, 10021
HEX "crtb" ID 1000	"${1}" \
${2,1.NULL}

${3,1.NULL}
text.

#footnote 1: repeat texts
#basically, everytime a repeat is called, it will expand the macros. Everytime 
#a file.variable macro is expanded it will get the next file found by find(1)
#and print it, with the options[2].

#footnote 2: options
#definitions can be passed various options either via the opts command in the
#definition, or from the source using the form ${def,option1,option2,option3,...}
# I have only defined a few options in this file: resetvars,noinc,stripext. resetvars 
#is explained in comments, noinc says that the file should not be incremented 
#(the index in the stored list returned by find(1)) or the variable's computation should 
#not be called before expanding, or that the repeat should expand the last repeat that was 
#done. For ease of use, this option would inherit to subsequent expansions. stripext tells
#file.variable that the file should be returned with the trailing . and all text after it to 
# be dropped. "hello_world.bmp" become "hello_world".