IRAF CL Script Notes

The following are some notes on the syntax for IRAF scripts so I don't forget what I did, and some notes on imexpr.

1. Create a new 512x512 image with zeros in it:
imexpr "repl(0,512)" imagename dim=512,512

2. Create a mask file identifying all pixels greater than 800:
imexpr "a > 800." a=imagename

3. Create a new image from image1 and image2 depending on the value of the mask
imexpr "c ? a : b" newimage a=image1 b=image2

4. Example of a script to take the three pieces of a HIRES image and put them into
a single file separated by 10 pixels, oriented so red is up and to the right.
The 'else' command gave me a syntax error for some reason.

imdel k*.fits
for (i=1;i<70;i=i+1) {
 imdel junk.fits
 mkimage junk.fits make 1. 2 "3230 4096" pixtype="real"
 chpixtype junk.fits junk.fits ushort
 if(i<10) {
 if(i>9) {
 imcopy (s1//"[1][-*,*]", "junk.fits[1:1070,4096:1]")
 imcopy (s1//"[2][-*,*]", "junk.fits[1081:2150,4096:1]")
 imcopy (s1//"[3][-*,*]", "junk.fits[2161:3230,4096:1]")
 imtranspose ("junk.fits[*,-*]", s2)