Index: /trunk/ippMonitor/def/camPendingExp.d
===================================================================
--- /trunk/ippMonitor/def/camPendingExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/camPendingExp.d	(revision 13264)
@@ -6,6 +6,8 @@
 WHERE camPendingExp.chip_id = chipProcessedExp.chip_id
 
+ARGS  ARG1  chipProcessedExp.exp_tag=$chipProcessedExp.exp_tag
+
 #     field                     size  name          show   link to                  extras
-FIELD chipProcessedExp.exp_tag,	20,   exposure ID,  value, chipProcessedImfile.php, chipProcessedExp.exp_tag=$chipProcessedExp.exp_tag
-FIELD camPendingExp.chip_id,    20,   chip ID,      value, chipProcessedExp.php,    exp_tag=$chipProcessedExp.exp_tag
+FIELD chipProcessedExp.exp_tag,	20,   exposure ID,  value, chipProcessedImfile.php, ARG1
+FIELD camPendingExp.chip_id,    20,   chip ID,      value, chipProcessedExp.php,    ARG1
 FIELD camPendingExp.cam_id,     20,   cam ID
Index: /trunk/ippMonitor/def/camProcessedExp.d
===================================================================
--- /trunk/ippMonitor/def/camProcessedExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/camProcessedExp.d	(revision 13264)
@@ -1,3 +1,3 @@
-TABLE camProcessedExp, chipProcessedExp
+TABLE camProcessedExp, chipProcessedExp, rawExp
 TITLE Camera-Level Processed Exposures
 FILE  camProcessedExp.php
@@ -5,8 +5,18 @@
 
 WHERE camProcessedExp.chip_id = chipProcessedExp.chip_id
+WHERE camProcessedExp.exp_tag = rawExp.exp_tag
 
-#     field                           size  name       show                            link to                  extras
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG  $camProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+# show all chips for this camera exposure, summary stats from the camera tables
+ARGS  ARG1  camera=$rawExp.camera
+ARGS  ARG1  basename=$camProcessedExp.path_base
+ARGS  ARG1  exp_tag=$chipProcessedExp.exp_tag
+
+#     field                           size  name       show        link to                  extras
 FIELD chipProcessedExp.exp_tag,       15,   Exposure,  value
-FIELD *, 	     		      8,    image,     image=$camProcessedExp.path_base@PPIMAGE.JPEG2, chipProcessedImfile.php, exp_tag=$chipProcessedExp.exp_tag,image=$$camProcessedExp.path_base@PPIMAGE.JPEG1
+FIELD *, 	     		      8,    image,     image=JPEG, chipProcessedImfile.php, ARG1
 FIELD camProcessedExp.bg,	      8,    backgnd,   value
 FIELD camProcessedExp.bg_mean_stdev,  8,    [stdev],   value
Index: /trunk/ippMonitor/def/chipPendingExp.d
===================================================================
--- /trunk/ippMonitor/def/chipPendingExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/chipPendingExp.d	(revision 13264)
@@ -4,7 +4,9 @@
 MENU  ipp.science.dat
 
+ARGS  ARG1  exp_tag=$exp_tag
+
 #     field          size  name         show    link to         extras
 FIELD chip_id,       20,   chip ID
-FIELD exp_tag,       20,   exposure ID, value,  rawImfile.php,  exp_tag=$exp_tag
+FIELD exp_tag,       20,   exposure ID, value,  rawImfile.php,  ARG1
 FIELD recipe,	     20,   recipe
 FIELD guide_id,      20,   guide ID
Index: /trunk/ippMonitor/def/chipProcessedExp.d
===================================================================
--- /trunk/ippMonitor/def/chipProcessedExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/chipProcessedExp.d	(revision 13264)
@@ -4,8 +4,10 @@
 MENU  ipp.science.dat
 
-#     field          name  show           link to  extras
-FIELD exp_tag,       20,   exposure ID,   value,   chipProcessedImfile.php,  exp_tag=$exp_tag
+ARGS  ARG1  exp_tag=$exp_tag
+
+#     field          size  name           show     link to                   extras
+FIELD exp_tag,       20,   exposure ID,   value,   chipProcessedImfile.php,  ARG1
 FIELD chip_id,       20,   Chip ID
-FIELD guide_id,      20,   guide ID,      value,   guideProcessedExp.php,    exp_tag=$exp_tag
+FIELD guide_id,      20,   guide ID,      value,   guideProcessedExp.php,    ARG1
 FIELD label,         20,   label
 FIELD workdir,       20,   workdir
Index: /trunk/ippMonitor/def/chipProcessedImfile.d
===================================================================
--- /trunk/ippMonitor/def/chipProcessedImfile.d	(revision 13263)
+++ /trunk/ippMonitor/def/chipProcessedImfile.d	(revision 13264)
@@ -13,3 +13,3 @@
 FIELD chipProcessedImfile.bg_stdev,	  8,    stdev
 
-TAIL PHP insert_image ('image');
+TAIL PHP insert_image ('PPIMAGE_JPEG1');
Index: /trunk/ippMonitor/def/detInputExp.d
===================================================================
--- /trunk/ippMonitor/def/detInputExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/detInputExp.d	(revision 13264)
@@ -4,13 +4,16 @@
 MENU  ipp.detrend.dat
 
-# HEAD HTML  test head 1 <br>
+ARGS  ARG1  exp_tag=$exp_tag
 
-#     field      width 	name        show         link to                       extras
+ARGS  ARG2  exp_tag=$exp_tag
+ARGS  ARG2  det_id=$det_id
+ARGS  ARG2  iteration=$iteration
+
+#     field      width 	name        show         link to                 extras
 FIELD det_id,    7,    	det_id
-FIELD exp_tag,   20,   	exposure,   value,       rawImfile.php,          exp_tag=$exp_tag
+FIELD exp_tag,   20,   	exposure,   value,       rawImfile.php,          ARG1
 FIELD iteration, 5,    	iteration
 FIELD include,   7,   	include
-FIELD *,         5,    	resid,      value=goto,  detResidImfile.php,     exp_tag=$exp_tag,det_id=$det_id,iteration=$iteration
-FIELD *,         5,    	proc,       value=goto,  detProcessedImfile.php, exp_tag=$exp_tag,det_id=$det_id,iteration=$iteration
+FIELD *,         5,    	resid,      value=goto,  detResidImfile.php,     ARG2
+FIELD *,         5,    	proc,       value=goto,  detProcessedImfile.php, ARG2
 
-# TAIL HTML  test tail 1 <br>
Index: /trunk/ippMonitor/def/detNormalizedExp.d
===================================================================
--- /trunk/ippMonitor/def/detNormalizedExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/detNormalizedExp.d	(revision 13264)
@@ -1,14 +1,26 @@
-TABLE detNormalizedExp
+TABLE detNormalizedExp, rawExp
 TITLE detNormalizedExp
 FILE  detNormalizedExp.php
 MENU  ipp.detrend.dat
 
-#     field        size     name       show            link to                  extras
-FIELD det_id,        7,     det_id
-FIELD bg,            8,     backgnd
-FIELD bg_mean_stdev, 8,     [stdev]
-FIELD bg_stdev,      8,     stdev
-FIELD iteration,     5,     iteration
-FIELD *,             8,     image,     image=$path_base@PPIMAGE.JPEG2,  detNormalizedImfile.php, det_id=$det_id,iteration=$iteration,image=$path_base@PPIMAGE.JPEG1
-FIELD path_base,     20,    path_base, none
-#FIELD recipe, 20,   recipe
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detNormalizedExp.exp_tag = rawExp.exp_tag
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detNormalizedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+ARGS  ARG2 det_id=$detNormalizedExp.det_id
+ARGS  ARG2 iteration=$detNormalizedExp.iteration
+ARGS  ARG2 exp_tag=$detNormalizedExp.exp_tag
+ARGS  ARG2 camera=$rawExp.camera
+ARGS  ARG2 basename=$detNormalizedExp.path_base
+
+#     field        		      size     name     show          link to                  extras
+FIELD detNormalizedExp.det_id,        7,     det_id
+FIELD detNormalizedExp.bg,            8,     backgnd
+FIELD detNormalizedExp.bg_mean_stdev, 8,     [stdev]
+FIELD detNormalizedExp.bg_stdev,      8,     stdev
+FIELD detNormalizedExp.iteration,     5,     iteration
+FIELD *,             		      8,     image,     image=JPEG2,  detNormalizedImfile.php, ARG2
+FIELD detNormalizedExp.path_base,     20,    path_base, none
Index: /trunk/ippMonitor/def/detNormalizedImfile.d
===================================================================
--- /trunk/ippMonitor/def/detNormalizedImfile.d	(revision 13263)
+++ /trunk/ippMonitor/def/detNormalizedImfile.d	(revision 13264)
@@ -14,3 +14,3 @@
 #FIELD path_base,     20, path_base
 
-TAIL PHP insert_image ('image');
+TAIL PHP insert_image ('PPIMAGE_JPEG1');
Index: /trunk/ippMonitor/def/detProcessedExp.d
===================================================================
--- /trunk/ippMonitor/def/detProcessedExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/detProcessedExp.d	(revision 13264)
@@ -1,14 +1,30 @@
-TABLE detProcessedExp
+TABLE detProcessedExp, rawExp
 TITLE detProcessedExp
 FILE  detProcessedExp.php
 MENU  ipp.detrend.dat
 
-#     field     size   name       show            link to                 extras
-FIELD det_id,     7,   Det ID,    value
-FIELD exp_tag, 	 15,   Exposure,  value
-FIELD *, 	  8,   image,     image=$path_base@PPIMAGE.JPEG2,  detProcessedImfile.php, det_id=$det_id,exp_tag=$exp_tag,image=$path_base@PPIMAGE.JPEG1
-FIELD bg, 	  8,   backgnd,   value
-FIELD bg_mean_stdev, 8, [stdev],  value
-FIELD bg_stdev,   8,   stdev,     value
-FIELD recipe,    15,   Recipe,    value
-FIELD path_base, 20,   path_base, none
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedExp.exp_tag = rawExp.exp_tag
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+ARGS  ARG1 det_id=$detProcessedExp.det_id
+ARGS  ARG1 exp_tag=$detProcessedExp.exp_tag
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detProcessedExp.path_base
+
+#     field                    size    	name       show          link to                 extras
+FIELD detProcessedExp.det_id,     7,   	Det ID,    value
+FIELD rawExp.camera,             10,    camera,    value
+FIELD detProcessedExp.exp_tag, 	 15,   	Exposure,  value
+FIELD *, 	  		  8,   	image,     image=JPEG2,  detProcessedImfile.php, ARG1
+FIELD detProcessedExp.bg, 	  8,   	backgnd,   value
+FIELD detProcessedExp.bg_mean_stdev, 8,	[stdev],   value
+FIELD detProcessedExp.bg_stdev,   8,   	stdev,     value
+FIELD detProcessedExp.recipe,    15,   	Recipe,    value
+FIELD detProcessedExp.path_base, 20,   	path_base, none
+
+# note: you must include all desired fields, where ever they are used,
+# in FIELD
Index: /trunk/ippMonitor/def/detProcessedImfile.d
===================================================================
--- /trunk/ippMonitor/def/detProcessedImfile.d	(revision 13263)
+++ /trunk/ippMonitor/def/detProcessedImfile.d	(revision 13264)
@@ -15,3 +15,3 @@
 # FIELD path_base,  20,   path_base
 
-TAIL PHP insert_image ('image');
+TAIL PHP insert_image ('PPIMAGE_JPEG1');
Index: /trunk/ippMonitor/def/detResidExp.d
===================================================================
--- /trunk/ippMonitor/def/detResidExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/detResidExp.d	(revision 13264)
@@ -8,19 +8,25 @@
 
 # define image names to be used below
-VALUE JPEG1 $detResidExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detResidExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
 
-#     field                   size    name       show    link to              extras
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1 exp_tag=$detResidExp.exp_tag
+
+ARGS  ARG2 det_id=$detResidExp.det_id
+ARGS  ARG2 iteration=$detResidExp.iteration
+ARGS  ARG2 exp_tag=$detResidExp.exp_tag
+ARGS  ARG2 camera=$rawExp.camera
+ARGS  ARG2 basename=$detResidExp.path_base
+
+#     field                   size    name       show         link to              linkargs
 FIELD detResidExp.det_id,        7,   Det ID,    value
-FIELD detResidExp.exp_tag, 	15,   Exposure,  value,  rawImfile.php,       exp_tag=$exp_tag
+FIELD detResidExp.exp_tag, 	15,   Exposure,  value,       rawImfile.php,       ARG1
 FIELD detResidExp.bg,            8,   backgnd,   value
 FIELD detResidExp.bg_mean_stdev, 8,   [stdev]
 FIELD detResidExp.bg_stdev,      8,   stdev,     value
 FIELD detResidExp.iteration,     5,   iter,      value
-FIELD *,    	                 8,   image,     image=JPEG1, detResidImfile.php, det_id=$det_id,iteration=$iteration,exp_tag=$exp_tag,image=1
+FIELD *,    	                 8,   image,     image=JPEG2, detResidImfile.php,  ARG2
 FIELD detResidExp.accept,        4,   keep,      value
-FIELD detResidExp.path_base,    20,   path_base, none
-
-# FIELD recipe,     15,    recipe,    value
-
-# ipp_filename.pl --filerule $rule --basename $name --camera $camera --class_id $class_id
-# getimage.php name=$1 rule=$2 camera=$3 class_id=$4
+FIELD detResidExp.path_base,    20,   path_base,  none
+FIELD rawExp.camera,            20,   camera,     none
Index: /trunk/ippMonitor/def/detResidImfile.d
===================================================================
--- /trunk/ippMonitor/def/detResidImfile.d	(revision 13263)
+++ /trunk/ippMonitor/def/detResidImfile.d	(revision 13264)
@@ -16,3 +16,4 @@
 # FIELD path_base,  20,   path_base
 
-TAIL PHP insert_image ('image');
+TAIL PHP insert_image ('PPIMAGE_JPEG1');
+TAIL PHP insert_image ('PPIMAGE_JPEG2');
Index: /trunk/ippMonitor/def/detRun.d
===================================================================
--- /trunk/ippMonitor/def/detRun.d	(revision 13263)
+++ /trunk/ippMonitor/def/detRun.d	(revision 13264)
@@ -4,6 +4,8 @@
 MENU  ipp.detrend.dat
 
+ARGS  ARG1 det_id=$det_id
+
 #     field       width name         show    link to              extras
-FIELD det_id,        7,   det ID,      value,  detRunSummary.php,   det_id=$det_id
+FIELD det_id,        7,   det ID,      value,  detRunSummary.php,   ARG1
 FIELD iteration,     5,   iteration
 FIELD det_type,      8,   det_type
Index: /trunk/ippMonitor/def/detRunSummary.d
===================================================================
--- /trunk/ippMonitor/def/detRunSummary.d	(revision 13263)
+++ /trunk/ippMonitor/def/detRunSummary.d	(revision 13264)
@@ -4,10 +4,13 @@
 MENU  ipp.detrend.dat
 
+ARGS  ARG1  det_id=$det_id
+ARGS  ARG1  iteration=$iteration
+
 #     field      name             show         link to           extras
 FIELD det_id,    7,    det_id    
 FIELD iteration, 5,    iter
 FIELD accept,    4,    keep
-FIELD *,         20,   choose,    value=input, detInputExp.php,  det_id=$det_id,iteration=$iteration
-FIELD *,         20,   choose,    value=resid, detResidExp.php,  det_id=$det_id,iteration=$iteration
+FIELD *,         20,   choose,    value=input, detInputExp.php,  ARG1
+FIELD *,         20,   choose,    value=resid, detResidExp.php,  ARG1
 FIELD bg,        20,   bg
 FIELD bg_stdev,  20,   bg_stdev
Index: /trunk/ippMonitor/def/example.d
===================================================================
--- /trunk/ippMonitor/def/example.d	(revision 13263)
+++ /trunk/ippMonitor/def/example.d	(revision 13264)
@@ -12,10 +12,13 @@
 WHERE detRun.iteration = detRunSummary.iteration
 
+ARGS  ARG1 det_id=$detRunSummary.det_id
+ARGS  ARG1 iteration=$detRunSummary.iteration
+
 #     field                    width name           show         link to           extras
 FIELD detRunSummary.det_id,    7,    det_id
 FIELD detRun.det_type,         5,    type
 FIELD detRunSummary.iteration, 5,    iter
-FIELD *,                       20,   choose,       value=input, detInputExp.php,  det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
-FIELD *,                       20,   choose,       value=resid, detResidExp.php,  det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
+FIELD *,                       20,   choose,       value=input, detInputExp.php,  ARG1
+FIELD *,                       20,   choose,       value=resid, detResidExp.php,  ARG1
 FIELD detRunSummary.bg,        20,   bg
 FIELD detRunSummary.bg_stdev,  20,   bg_stdev
Index: /trunk/ippMonitor/def/guidePendingExp.d
===================================================================
--- /trunk/ippMonitor/def/guidePendingExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/guidePendingExp.d	(revision 13264)
@@ -4,6 +4,8 @@
 MENU  ipp.science.dat
 
+ARGS  ARG1  exp_tag=$exp_tag
+
 #     field       name         show     link to         extras
-FIELD exp_tag,     20,   exposure ID, value,   rawImfile.php,  exp_tag=$exp_tag
+FIELD exp_tag,     20,   exposure ID, value,   rawImfile.php,  ARG1
 FIELD recipe,	  20,   recipe
 FIELD guide_version, 20,   guide version
Index: /trunk/ippMonitor/def/masterDetrendFrames.d
===================================================================
--- /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 13263)
+++ /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 13264)
@@ -12,11 +12,16 @@
 WHERE detRun.iteration = detRunSummary.iteration
 
+ARGS  ARG1 det_id=$detRunSummary.det_id
+
+ARGS  ARG2 det_id=$detRunSummary.det_id
+ARGS  ARG2 iteration=$detRunSummary.iteration
+
 #     field                    width name          show         link to                   extras
-FIELD detRunSummary.det_id,    7,    det_id,       value,       detRunSummary.php,        det_id=$detRunSummary.det_id
+FIELD detRunSummary.det_id,    7,    det_id,       value,       detRunSummary.php,        ARG1
 FIELD detRunSummary.iteration, 5,    iter
 FIELD detRun.det_type,         5,    type
-FIELD *,                       20,   choose,       value=files, detNormalizedImfiles.php, det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
-FIELD *,                       20,   choose,       value=input, detInputExp.php,          det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
-FIELD *,                       20,   choose,       value=resid, detResidExp.php,          det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
+FIELD *,                       20,   choose,       value=files, detNormalizedImfiles.php, ARG2 
+FIELD *,                       20,   choose,       value=input, detInputExp.php,          ARG2
+FIELD *,                       20,   choose,       value=resid, detResidExp.php,          ARG2
 FIELD detRunSummary.bg,        20,   bg
 FIELD detRunSummary.bg_stdev,  20,   bg_stdev
Index: /trunk/ippMonitor/def/rawDetrendExp.d
===================================================================
--- /trunk/ippMonitor/def/rawDetrendExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/rawDetrendExp.d	(revision 13264)
@@ -7,6 +7,8 @@
 WHERE rawExp.exp_type != 'OBJECT'
 
+ARGS ARG1 exp_tag=$exp_tag
+
 #        field        name  show           link to  extras
-FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php,  exp_tag=$exp_tag
+FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php,  ARG1
 FIELD    telescope,   10,   Telescope
 FIELD    camera,      10,   Camera
Index: /trunk/ippMonitor/def/rawDetrendExp_detrend.d
===================================================================
--- /trunk/ippMonitor/def/rawDetrendExp_detrend.d	(revision 13263)
+++ /trunk/ippMonitor/def/rawDetrendExp_detrend.d	(revision 13264)
@@ -7,6 +7,8 @@
 WHERE rawExp.exp_type != 'OBJECT'
 
-#        field        name           show     link to         extras
-FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php,  exp_tag=$exp_tag
+ARGS ARG1 exp_tag=$exp_tag
+
+#        field        size  name           show     link to         extras
+FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php,  ARG1
 FIELD    telescope,   10,   Telescope
 FIELD    camera,      10,   Camera
Index: /trunk/ippMonitor/def/rawScienceExp.d
===================================================================
--- /trunk/ippMonitor/def/rawScienceExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/rawScienceExp.d	(revision 13264)
@@ -7,17 +7,21 @@
 WHERE rawExp.exp_type = 'OBJECT'
 
-#        field        name           show          link to   extras
-FIELD    exp_tag,     10,   	     exposure Tag, value,    rawImfile.php,  exp_tag=$exp_tag,camera=$camera,foo=bar
-FIELD    telescope,   10,   	     Telescope,    value,    telescopes.php
-FIELD    camera,      10,   	     Camera
-FIELD    exp_type,     8,   	     Type    
-FIELD    filter,      10,   	     FILTER
-FIELD    ra,           8,   	     ra          
-FIELD    decl,         8,   	     decl        
-FIELD    object,      10,   	     object
-FIELD    airmass,      5,   	     airmass     
-FIELD    exp_time,     5,   	     exp_time    
-FIELD    bg,           5,   	     bg          
-FIELD    bg_stdev,     5,   	     bg_stdev    
+ARGS ARG1 exp_tag=$exp_tag
+ARGS ARG1 camera=$camera
+ARGS ARG1 foo=bar
+
+#        field        size name           show          link to   extras
+FIELD    exp_tag,     10,  exposure Tag, value,    rawImfile.php,  ARG1
+FIELD    telescope,   10,  Telescope,    value,    telescopes.php
+FIELD    camera,      10,  Camera
+FIELD    exp_type,     8,  Type    
+FIELD    filter,      10,  FILTER
+FIELD    ra,           8,  ra          
+FIELD    decl,         8,  decl        
+FIELD    object,      10,  object
+FIELD    airmass,      5,  airmass     
+FIELD    exp_time,     5,  exp_time    
+FIELD    bg,           5,  bg          
+FIELD    bg_stdev,     5,  bg_stdev    
 # FIELD    imfiles, 20,   imfiles     
 # FIELD    bg_mean_stdev, 20,   bg_mean_stdev   
Index: /trunk/ippMonitor/def/rawUnknownExp.d
===================================================================
--- /trunk/ippMonitor/def/rawUnknownExp.d	(revision 13263)
+++ /trunk/ippMonitor/def/rawUnknownExp.d	(revision 13264)
@@ -7,6 +7,8 @@
 WHERE rawExp.exp_type is NULL
 
-#        field        name  show           link to  extras
-FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php,  exp_tag=$exp_tag
+ARGS ARG1 exp_tag=$exp_tag
+
+#        field        size  name           show     link to        extras
+FIELD    exp_tag,     10,   exposure ID,   value,   rawImfile.php, ARG1 
 FIELD    telescope,   10,   Telescope
 FIELD    camera,      10,   Camera
Index: /trunk/ippMonitor/generate
===================================================================
--- /trunk/ippMonitor/generate	(revision 13263)
+++ /trunk/ippMonitor/generate	(revision 13264)
@@ -14,4 +14,5 @@
 # @headcode, @tailcode                 : additional HTML or PHP code before or after table
 # @field, @width, @name, @show, @link, @extras : properties of each table column
+# @imagedefs, %image: array of image defines
 
 &parse_schema;
@@ -61,4 +62,14 @@
  	if ($key eq "HEAD") {
 	    push @headcode, $value;
+	}
+
+	# the IMAGE commands sets up a reference name
+	if ($key eq "IMAGE") {
+	    push @imagedefs, $value;
+	}
+
+	# the IMAGE commands sets up a reference name
+	if ($key eq "ARGS") {
+	    push @linkargs, $value;
 	}
 
@@ -94,4 +105,12 @@
     &define_where_string (@where);
 
+    foreach $linkarg (@linkargs) {
+	&parse_linkarg ($linkarg);
+    }
+
+    foreach $imagedef (@imagedefs) {
+	&parse_imagedef ($imagedef);
+    }
+
     if (0) {
 	print STDERR "show: $show[0]\n";
@@ -220,5 +239,5 @@
 	    printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
 	    # add extra GET data to target
-	    if ($extras[$i]) { &parse_extras ($extras[$i]); } 
+	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
 	    # print the actual table cell line with the link...
 	    if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
@@ -229,5 +248,5 @@
 	if (($label eq "image") && !$link[$i]) {
 	    # print the actual table cell line with the image...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"getimage.php?name=$value\\\"></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"$image{$value}\\\"></td>\\n\";\n";
 	    next;
 	}
@@ -237,7 +256,7 @@
 	    printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
 	    # add extra php data to target
-	    if ($extras[$i]) { &parse_extras ($extras[$i]); } 
+	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
 	    # print the actual table cell line with the link...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"getimage.php?name=$value\\\"> </a></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
 	    next;
 	}
@@ -314,4 +333,19 @@
 	printf FILE "  \$link = \$link . \"&$outline\";\n";
     }
+}
+
+# each linkarg is an entry of the form "word name=value"
+# the entries for matching words are concatenated together
+# separated by commas to create the value $linkarg{word}
+sub parse_linkarg {
+    my ($word, $value);
+
+    ($word, $value) = split (" ", $_[0]);
+
+    if ($linkarg{$word}) {
+	$linkarg{$word} = "$linkarg{$word},$value";
+    } else {
+	$linkarg{$word} = $value;
+    }	
 }
 
@@ -360,4 +394,47 @@
 }
 
+# given a variable of the form $fieldname, return the corresponding
+# row entry in the form $row[N], otherwise return $fieldname
+# globals: field (list of field names), count (list of sequence)
+sub parse_fieldname {
+    my ($variable) = $_[0];
+    my ($i);
+    
+    unless ($variable =~ m|^\$|) {
+	return $variable;
+    }
+
+    $fieldname = substr ($variable, 1);
+
+    print STDERR "fieldname: $fieldname\n";
+
+    for ($i = 0; $i < @field; $i++) {
+	print STDERR "$i: $field[$i] : $fieldname\n";
+
+	if ($field[$i] eq "*") { next; }
+	if ($fieldname ne $field[$i]) { next; }
+
+
+	$Nrow = $count[$i];
+
+	$value = "\$row[$Nrow]";
+
+	print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
+	return $value;
+    }
+    return $variable;
+}
+
+sub parse_imagedef {
+    my ($value) = $_[0];
+
+    ($var, $name, $rule, $camera, $class) = split (" ", $value);
+    $name   = &parse_fieldname ($name);
+    $camera = &parse_fieldname ($camera);
+    $class  = &parse_fieldname ($class);
+    $image{$var} = "getimage.php?name=$name&rule=$rule&camera=$camera&class_id=$class";
+    return 1;
+}
+
 sub init_key {
     my ($key)   = $_[0];
Index: /trunk/ippMonitor/raw/getimage.php
===================================================================
--- /trunk/ippMonitor/raw/getimage.php	(revision 13263)
+++ /trunk/ippMonitor/raw/getimage.php	(revision 13264)
@@ -47,4 +47,8 @@
 exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id", $output, $status);
 
+# use these to check the environment
+# passthru ("env");
+# passthru ("perl --version");
+
 $filename = $output[0];
 if ($status) {
Index: /trunk/ippMonitor/raw/ipp.php
===================================================================
--- /trunk/ippMonitor/raw/ipp.php	(revision 13263)
+++ /trunk/ippMonitor/raw/ipp.php	(revision 13264)
@@ -1,5 +1,5 @@
 <?php
 
-$dTABLE = 40;
+$dTABLE = 10;
 
 function logintext () {
@@ -316,14 +316,20 @@
 // expect image supplied with key=name
 // this function should define matching hidden inputs in the form
-function insert_image ($key) {
+function insert_image ($rule) {
 
   if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $name = $_GET[$key]; 
-  } else {
-    $name = $_POST[$key]; 
-  }
-
-  if ($name) {
-    echo "<img src=\"getimage.php?name=$name\">\n";
+    $basename = $_GET['basename']; 
+    $class_id = $_GET['class']; 
+    $camera   = $_GET['camera']; 
+  } else {
+    $basename = $_POST['basename']; 
+    $class_id = $_POST['class']; 
+    $camera   = $_POST['camera']; 
+  }
+
+  if (! $class_id) { $class_id = "NONE"; }
+
+  if ($basename && $camera && $rule) {
+    echo "<img src=\"getimage.php?name=$basename&rule=$rule&camera=$camera&class_id=$class_id\">\n";
   }
 }
