(FILECREATED "29-Jan-84 22:18:14" {PHYLUM}<BLUEBONNET>DMRUSSELL>DESCRIBEJOB.;5 52408  

      changes to:  (FNS FlashQuery ProceedFromPanel)

      previous date: "28-Jan-84 20:59:51" {PHYLUM}<BLUEBONNET>DMRUSSELL>DESCRIBEJOB.;4)


(PRETTYCOMPRINT DESCRIBEJOBCOMS)

(RPAQQ DESCRIBEJOBCOMS [(VARS (NumberOfCopiesTimer 0)
			      (NumberOfOriginalsTimer 0))
			(RECORDS * DESCRIBEJOBRECORDS)
			(FNS * DESCRIBEJOBFNS)
			(DECLARE: EVAL@COMPILE (P (LOADCOMP? 'LOADBLUEBONNET])

(RPAQQ NumberOfCopiesTimer 0)

(RPAQQ NumberOfOriginalsTimer 0)

(RPAQQ DESCRIBEJOBRECORDS (Derivation JobPanelField SelectableItem))
[DECLARE: EVAL@COMPILE 

(DATATYPE Derivation (resultField resultValue constraint givens))

(DATATYPE JobPanelField (queryItem valueItems internalUnionRegion selectedItem field visibleFlg)
			[ACCESSFNS ((unionRegion [OR (fetch internalUnionRegion of DATUM)
						     (replace internalUnionRegion of DATUM
							with (APPLY 'UNIONREGIONS
								    (CONS (fetch itemRegion
									     of (fetch queryItem
										   of DATUM))
									  (for i
									     in (fetch valueItems
										   of DATUM)
									     collect (fetch 
										       itemRegion
											of i]
						 (replace internalUnionRegion of DATUM with NEWVALUE])

(DATATYPE SelectableItem (itemRegion jobPanelField itemValue invertedFlg)
			 jobPanelField ← (create JobPanelField))
]
(/DECLAREDATATYPE 'Derivation '(POINTER POINTER POINTER POINTER))
(/DECLAREDATATYPE 'JobPanelField '(POINTER POINTER POINTER POINTER POINTER POINTER))
(/DECLAREDATATYPE 'SelectableItem '(POINTER POINTER POINTER POINTER))

(RPAQQ DESCRIBEJOBFNS (AddAssertion AddDerivation Advise1To2 Advise2To1WithMaster AdviseBdaWithMaster 
				    ApplyHelpUnits CommentOnJob CopyCopyJob CopyingTime 
				    CreateFieldItems DefineDefaultJob DeriveValue 
				    DeriveValuesForGenerators DerivedResult? DeselectItem 
				    EraseJobPanelField FindEnabledGenerators FlashQuery FlipItem 
				    FlipRegion GeneratorsTimeEstimate GetGeneratorParameters 
				    GiveUserQueryHelp HelpFromPanel InItem? InitiateDescriptionPanel 
				    JobFieldValue JobPanelButtonHandler JobPanelHelpHandler 
				    PrintAndBox PrintComment ProceedFromPanel RedisplayJobPanelField 
				    RedisplayMenu RedisplayMenuTitle RefreshPanel RelevantField? 
				    RemoveDerivationsOf RemoveValue ResolveNewJobValue 
				    SecondsToRoundedMinutes SelectItem SelectPlanGenerator 
				    SetJobField ShowTimeEstimate Subset? SupportsForDerivation 
				    TimeEstimateForJob TimeFor1To1 TimeFor1To2 TimeFor2To1WithMaster 
				    TimeForBdaNoMaster TimeForBdaWithMaster TimeForPlanners 
				    TimeForTooThick TimeToCollate TimeToReverseOriginals TimeToStaple 
				    UpdateJobField UpdateJobDescriptionPanel 
				    WhenNumberOfCopiesMenuSelected WhenOriginalsMenuSelected 
				    WhenPadMenuSelected))
(DEFINEQ

(AddAssertion
  [LAMBDA (job field value)                                  (* edited: "10-MAR-83 13:34")
                                                             (* Give field a new value in job.
							     If field had a value, then use RemoveValue to first 
							     remove it. Return the new value.)
    (if (JobFieldValue field job)
	~=value
	then (\TraceIt BluebonnetTrace "Assertion: " field " ← " value)
	     (RemoveValue field job)
	     (SetJobField job field value)
      else (RemoveDerivationsOf field job))
    value])

(AddDerivation
  [LAMBDA (derivation job)                                   (* edited: "10-MAR-83 13:34")

          (* Assign the result value to the result field as specified by the derivation and add the derivation to job.
	  Use RemoveValue to remove any existing value for the result field. Return derivation.)


    (if (JobFieldValue derivation:resultField job)
	~=derivation:resultValue
	then (\TraceIt BluebonnetTrace "Derivaton: " derivation:resultField " ← " 
		       derivation:resultValue))
    (RemoveValue derivation:resultField job)
    (if derivation:resultValue
	then (SetJobField job derivation:resultField derivation:resultValue)
	     job:derivations← <derivation ! job:derivations> derivation])

(Advise1To2
  [LAMBDA (job)                                              (* edited: " 1-FEB-83 11:52")
                                                             (* Provide an advise comment to the user about doing 1 
							     to 2 sided copying.)
    T])

(Advise2To1WithMaster
  [LAMBDA NIL                                                (* edited: "11-MAR-83 13:52")
    NIL])

(AdviseBdaWithMaster
  [LAMBDA (job)                                              (* edited: " 7-FEB-83 13:49")
                                                             (* Provide an advise comment to the user about using the
							     BDA to make a master.)
    (PROG (difference minutes hours subJobTime (collate? (AND job:Collate=(QUOTE Yes)
							      job:NumberOfCopies 
							      job:NumberOfCopies~=1))
		      (staple? (AND job:Staple=(QUOTE Yes)
				    job:CopiesTooThickToStaple=(QUOTE No)))
		      (twoSidedCopies? (job:TwoSidedCopies=(QUOTE Yes)))
		      (subJob (CopyCopyJob job)))
          (subJob:Collate←(QUOTE No))
          (subJob:Staple←(QUOTE No))
          (subJob:TwoSidedCopies←(QUOTE No))
          (subJobTime←(TimeForBdaNoMaster subJob)+(TimeToCollate job)+(TimeToStaple job))
          (difference←job:timeEstimate-subJobTime)
          (if difference gt 120 or (FQUOTIENT difference job:timeEstimate) gt .2
	      then subJobTime←(SecondsToRoundedMinutes subJobTime)
		   hours←subJobTime/60
		   minutes←(IREMAINDER subJobTime 60)
		   (PrintComment [BQUOTE (You could save yourself ,@ [COND
						((IGREATERP difference 120)
						  (BQUOTE (about , (SecondsToRoundedMinutes 
										       difference)
								 minutes)))
						(T (QUOTE (some time]
					      by ,@ [COND
						(twoSidedCopies?
						  (BQUOTE (making one-sided ,@
								  (COND
								    ((OR collate? staple?)
								      (QUOTE (copies, and)))
								    (T (QUOTE (copies.]
					      ,@
					      [COND
						(staple? (QUOTE (stapling]
					      ,@
					      [COND
						(collate? (BQUOTE (,@ [COND
									(staple? (QUOTE (and]
								      collating]
					      ,@
					      (COND
						((OR collate? staple?)
						  (QUOTE (the copies yourself.]
				 T])

(ApplyHelpUnits
  [LAMBDA (job)                                              (* edited: " 1-FEB-83 10:37")
                                                             (* Test each help unit for applicability and apply those
							     whose wff is true.)
    (for unit in HelpUnits when (EvalWff unit:HelpUnit.wff job)
       do (PrintComment unit:HelpUnit.text)
	  (for ch on unit:HelpUnit.changes
	     do (FlashQuery job ch:1:1)
		(if ch::1
		    then (AddAssertion job ch:1:1 ch:1::1)
			 (push job:relevantFields ch:1:1)
		  else (ResolveNewJobValue job ch:1:1 ch:1::1)))
	  (RETURN])

(CommentOnJob
  [LAMBDA (job)                                              (* edited: "14-JAN-83 14:55")
                                                             (* Display in the comment window the messages of any 
							     comment wff that is true.)
    (CLEARW CommentWindow)
    (for w in CommentWffs when (EvalWff w:Constraint.wff job) do (PrintComment w:Constraint.text T])

(CopyCopyJob
  [LAMBDA (job)                                              (* edited: " 4-FEB-83 13:28")
                                                             (* Make a copy of a copy job.
							     Do not copy any of the field values.)
    (PROG ((newJob (create CopyJob)))
          (for f in (RECORDFIELDNAMES (QUOTE CopyJob)) do (RECORDACCESS f newJob CopyJobRecord
									(QUOTE replace)
									(JobFieldValue f job)))
          (RETURN newJob])

(CopyingTime
  [LAMBDA (job)                                              (* edited: " 2-FEB-83 13:50")
                                                             (* Estimate the copying time in seconds for this job.)
    job:NumberOfCopies*job:#OfOriginalSheets*.86])

(CreateFieldItems
  [LAMBDA (field job window indentation)                     (* edited: " 2-FEB-83 10:50")
                                                             (* Create the items for copy job field for job in 
							     window. Return the list of items.)
    (PROG (vItem qItem jpf)
          (TERPRI window)
          (TERPRI window)
          (qItem←(create SelectableItem
			 itemRegion ←(PrintAndBox (GETP field (QUOTE query))
						  window indentation)))
          (jpf←qItem:jobPanelField)
          (WINDOWPROP window field jpf)
          (jpf:queryItem←qItem)
          (jpf:JobPanelField.field←field)
          (jpf:valueItems←(for v in (GETP field (QUOTE valueRange))
			     collect (SPACES 4 window)
				     (vItem←(create SelectableItem
						    itemRegion ←(PrintAndBox v window)
						    jobPanelField ← jpf
						    itemValue ← v))
				     (if v=(RECORDACCESS field job (RECLOOK (QUOTE CopyJob)))
					 then (SelectItem vItem window))
				     vItem))
          (jpf:visibleFlg←T)
          (if ~(RelevantField? field job)
	      then (EraseJobPanelField jpf window))
          (RETURN (COPY jpf:valueItems])

(DefineDefaultJob
  [LAMBDA (job)                                              (* edited: "31-JAN-83 13:37")
                                                             (* Assert the values that define a default copy job.
							     If job is NIL, then create a copy job.
							     Return the job.)
    (if job
	then (job:relevantFields←NIL)
      else job←(create CopyJob))
    job:relevantFields←(for spec in (QUOTE (#OfOriginalSheets CopiesOnStandardPaper CopyBrightness 
							      NumberOfCopies OriginalsBound 
							      OriginalsOnStandardPaper 
							      OriginalsStandardSize Staple 
							      TwoSidedCopies TwoSidedOriginals))
			  collect (AddAssertion job spec (GETPROP spec (QUOTE defaultValue)))
				  spec)
    (ResolveNewJobValue job (QUOTE Reduction)
			(GETPROP (QUOTE Reduction)
				 (QUOTE defaultValue)))
    job])

(DeriveValue
  [LAMBDA (field job fieldsBeingDerived)                     (* edited: "12-MAR-83 16:31")

          (* Use field's derivers to derive a value for field in job. If successful, return the support list for the 
	  derivation. If not, return the shortest support list for all of the deriver evaluations. Assume field is unvalued 
	  in job. fieldsBeingDerived is a list of fields that DeriveValue is being used to derive. It acts as a goal stack 
	  for recursive calls to DeriveValue and is used to prevent looping.)


    (PROG (val support unprocessedDerivers)
          (for deriver in (GETPROP field (QUOTE derivers))
	     do (if (for f in deriver:otherFields always (JobFieldValue f job))
		    then val←(EvalCompactOr deriver:compactOr job T)
			 (if val:1
			     then (push support val::1)
			   else (AddDerivation (create Derivation
						       resultField ← field
						       resultValue ←(EvalWff deriver:value job)
						       constraint ← deriver:Deriver.constraint
						       givens ← deriver:otherFields)
					       job)
				(RETFROM (QUOTE DeriveValue)
					 (SupportsForDerivation field job)))
		  else (push unprocessedDerivers deriver)))
          (RETURN (for deriver in unprocessedDerivers bind (newGoalStack ← <field ! 
									      fieldsBeingDerived>)
		     do (for f in deriver:otherFields unless (JobFieldValue f job)
							       or f MEMB fieldsBeingDerived
			   do (DeriveValue f job newGoalStack))
			(val←(EvalCompactOr deriver:compactOr job T))
			(if val:1
			    then (push support val::1)
			  elseif (for f in deriver:otherFields always (JobFieldValue f job))
			    then (AddDerivation (create Derivation
							resultField ← field
							resultValue ←(EvalWff deriver:value job)
							constraint ← deriver:Deriver.constraint
							givens ← deriver:otherFields)
						job)
				 (RETURN (SupportsForDerivation field job)))
		     finally (RETURN (ShortestSupport (CombineSupports
							(for struc in support
							   collect (for sList in struc
								      collect (for s in sList
										 join (
SupportsForDerivation s job) or <s>])

(DeriveValuesForGenerators
  [LAMBDA (job)                                              (* edited: " 4-FEB-83 15:08")

          (* Determine the enabled generators for this job and use the derivation constraints to determine values for 
	  unvalued fields relevant to the generator determination. If the constraints do not provide a value for a field 
	  assign its previous value or if none its default value. Return a dotted pair, the first element of which is a list
	  of enabled generators, and the second element is a list of relevant fields.)


    (PROG (gens unprocessedFields newValue? newSupportValue? relevantFields supports)
          [repeatwhile newValue?
	     do (newValue?←relevantFields←NIL)
		(gens←(FindEnabledGenerators job))
		(unprocessedFields←gens::1)
		(for f in unprocessedFields
		   do (if (JobFieldValue f job)
			  then (pushlist relevantFields (SupportsForDerivation f job))
			else (repeatwhile newSupportValue?
				do (newSupportValue?←NIL)
				   (supports←(DeriveValue f job))
				   (if (JobFieldValue f job)
				       then newValue?←(pushlist relevantFields supports)
				     else (for s in supports unless (JobFieldValue s job)
					     do newSupportValue?←([AddAssertion
						   job s (OR (LISTGET job:removedAssertions s)
							     (GETPROP s (QUOTE defaultValue]
						   or newSupportValue?))
					  (if ~newSupportValue?
					      then (push relevantFields f)
						   (if [AddAssertion job f
								     (OR (LISTGET 
									    job:removedAssertions f)
									 (GETPROP f (QUOTE 
										     defaultValue]
						       then newValue?←T
						     else (pushlist relevantFields supports]
          [for f in (for g in gens:1 join (GetGeneratorParameters g job))
	     do (if (JobFieldValue f job)
		    then (pushlist relevantFields (SupportsForDerivation f job))
		  else (repeatwhile newSupportValue?
			  do (newSupportValue?←NIL)
			     (supports←(DeriveValue f job))
			     (if (JobFieldValue f job)
				 then (pushlist relevantFields supports)
			       else (for s in supports unless (JobFieldValue s job)
				       do newSupportValue?←([AddAssertion job s
									  (OR (LISTGET 
									    job:removedAssertions s)
									      (GETPROP s
										       (QUOTE 
										     defaultValue]
					     or newSupportValue?))
				    (if ~newSupportValue?
					then (push relevantFields f)
					     (if ~[AddAssertion job f (OR (LISTGET 
									    job:removedAssertions f)
									  (GETPROP f (QUOTE 
										     defaultValue]
						 then (pushlist relevantFields supports]
          (RETURN <gens:1 ! relevantFields>])

(DerivedResult?
  [LAMBDA (field job)                                        (* ref: " 9-JUN-82 10:48")
                                                             (* Determine whether field is a result field of any 
							     derivations in job. Return the list of derivations.)
    (for d in job:derivations when d:resultField=field collect d])

(DeselectItem
  [LAMBDA (item window)                                      (* ref: "26-MAY-82 15:57")
                                                             (* deselects item from window)
    (if item and item:jobPanelField:selectedItem=item
	then (FlipItem item window)
	     item:jobPanelField:selectedItem←NIL])

(EraseJobPanelField
  [LAMBDA (jpField window)                                   (* ref: " 1-JUN-82 15:44")
                                                             (* White out the regions of the given job panel field in
							     window.)
    (if jpField and jpField:visibleFlg
	then (DSPFILL jpField:unionRegion WHITESHADE 'REPLACE window)
	     jpField:visibleFlg←NIL
	     jpField:selectedItem←NIL])

(FindEnabledGenerators
  [LAMBDA (job)                                              (* edited: " 2-FEB-83 11:37")

          (* Return a dotted pair the first element of which is a list of plan generators whose enabling conditions are 
	  satisfied by job, the second of which is a list of fields that support the evaluation of the enabling conditions.)


    (PROG (support generators val)
          (for gen in PlanGenerators
	     do (val←(EvalWff gen:enablingCondition job T))
		(if val:1
		    then (push generators gen))
		(push support val::1))
          (RETURN <generators !(ShortestSupport (CombineSupports support))
		    >])

(FlashQuery
  [LAMBDA (job field)                                        (* JG "28-Jan-84 23:26")
                                                             (* Flash the field%'s query on the job description 
							     panel.)
    (for i to 5 bind ((panel ← (fetch descriptionPanel of job))
		      item)
       first (SETQ item (fetch queryItem of (WINDOWPROP panel field)))
       do (FlipItem item panel)
	  (DISMISS 250])

(FlipItem
  [LAMBDA (item ds)                                          (* ref: "30-AUG-82 17:59")
                                                             (* flips the region of an item)
    (FlipRegion item:itemRegion ds)
    item:invertedFlg←~(item : invertedFlg])

(FlipRegion
  [LAMBDA (reg ds)                                           (* ref: "16-JUN-82 14:20")
                                                             (* flips a region.)
    (BITBLT NIL NIL NIL ds reg:LEFT reg:BOTTOM reg:WIDTH reg:HEIGHT 'TEXTURE 'INVERT BLACKSHADE])

(GeneratorsTimeEstimate
  [LAMBDA (gen job)                                          (* edited: "13-MAR-83 22:52")
                                                             (* Use the plan generator's time estimator to determine 
							     a time estimate for doing the job.)
    (if gen:timeEstimator
	then (APPLY* gen:timeEstimator job)
      else 0])

(GetGeneratorParameters
  [LAMBDA (gen job)                (* edited: " 4-FEB-83 07:49")
                                   (* Return a list of copy job fields that this plan generator uses to construct 
				   its plan.)
    (OR (LISTP gen:parameters)
	(APPLY* gen:parameters job])

(GiveUserQueryHelp
  [LAMBDA (job field queryItem)                              (* edited: "28-JAN-83 15:52")
                                                             (* Print a help message for the given field in the 
							     comment window.)
    (PrintComment (OR (GETPROP field (QUOTE helpMessage))
		      DefaultQueryHelpMessage))
    (WINDOWPROP job:descriptionPanel (QUOTE BUTTONEVENTFN)
		(QUOTE JobPanelButtonHandler])

(HelpFromPanel
  [LAMBDA (panel)                                            (* edited: "28-JAN-83 15:37")
                                                             (* Help function for the job description panel.)
    (PrintComment (QUOTE (Select the question you would like help with.)))
    (WINDOWPROP panel (QUOTE BUTTONEVENTFN)
		(QUOTE JobPanelHelpHandler])

(InItem?
  [LAMBDA (items pos)                                        (* ref: "20-MAY-82 12:34")
    (PROG ((XPOS (pos:XCOORD))
	   (YPOS (pos:YCOORD)))
          (RETURN (for ITEM in items when ITEM:itemRegion and (INSIDE? ITEM:itemRegion XPOS YPOS)
		     do (RETURN ITEM])

(InitiateDescriptionPanel
  [LAMBDA (copyJob)                                          (* JG "28-Jan-84 20:59")
                                                             (* Create a job description panel and comment window for
							     copyJob. Return the description panel.)
    (PROG [originalsItem yPos numberItem padMenu originalsMenu font jpField
			 (w (CREATEW (create REGION
					     LEFT ← 10
					     BOTTOM ← 0
					     WIDTH ← 700
					     HEIGHT ← 808]
          (WINDOWPROP w 'RIGHTBUTTONFN (FUNCTION [LAMBDA NIL NIL]))
          (DSPFONT TimesRomanD24 w)                          (* *JG DSPFONT moved before MOVETOUPPERLEFT)
          (MOVETOUPPERLEFT w)
          (printout w "Describe the document to be copied:")
          (DSPFONT Gacha12Bold w)
          (WINDOWPROP w 'SelectableItems (for f in OriginalsFields join (CreateFieldItems f copyJob w 
											  5)))
          (printout w T T)
          (font← (DSPFONT Gacha12Bold WindowTitleDisplayStream))
          (yPos← (DSPYPOSITION NIL w))
          (originalsMenu← (create MENU
				  MENUFONT ← Gacha12Bold
				  ITEMS ←
				  '(1 2 3 4 5 6 7 8 9 "" 0 Clear)
				  CENTERFLG ← T
				  MENUCOLUMNS ← 3
				  ITEMHEIGHT ← 25
				  ITEMWIDTH ← 40
				  TITLE ← (GETPROP '#OfOriginalSheets 'defaultValue)
				  WHENSELECTEDFN ← 'WhenOriginalsMenuSelected))
          (WINDOWPROP w '#OfOriginalSheetsMenu originalsMenu)
          (RELMOVETO 0 (- (originalsMenu:IMAGEHEIGHT/2))
		     w)
          (originalsItem← (create SelectableItem
				  itemRegion ← (PrintAndBox (GETPROP '#OfOriginalSheets 'query)
							    w 5)))
          (originalsItem:jobPanelField:JobPanelField.field← '#OfOriginalSheets)
          (originalsItem:jobPanelField:queryItem←originalsItem)
          (originalsItem:jobPanelField:visibleFlg←T)
          (WINDOWPROP w '#OfOriginalSheets originalsItem:jobPanelField)
          (originalsMenu:MENUPOSITION← (create POSITION
					       XCOORD ← (
				  originalsItem:itemRegion:LEFT+originalsItem:itemRegion:WIDTH+10)
					       YCOORD ← (yPos-originalsMenu:IMAGEHEIGHT)))
          (ADDMENU originalsMenu w)
          (MOVETO 0 originalsMenu:MENUGRID:REGION.BOTTOM-5 w)
          (DSPFONT TimesRomanD24 w)
          (printout w T "Describe the desired copies:")
          (DSPFONT Gacha12Bold w)
          (printout w T)
          (yPos← (DSPYPOSITION NIL w))
          (padMenu← (create MENU
			    MENUFONT ← Gacha12Bold
			    ITEMS ←
			    '(1 2 3 4 5 6 7 8 9 "" 0 Clear)
			    CENTERFLG ← T
			    MENUCOLUMNS ← 3
			    ITEMHEIGHT ← 25
			    ITEMWIDTH ← 40
			    TITLE ← (GETPROP 'NumberOfCopies 'defaultValue)
			    WHENSELECTEDFN ← 'WhenNumberOfCopiesMenuSelected))
          (WINDOWPROP w 'NumberOfCopiesMenu padMenu)
          (RELMOVETO 0 (- (padMenu:IMAGEHEIGHT/2))
		     w)
          (numberItem← (create SelectableItem
			       itemRegion ← (PrintAndBox (GETPROP 'NumberOfCopies 'query)
							 w 5)))
          (numberItem:jobPanelField:JobPanelField.field← 'NumberOfCopies)
          (numberItem:jobPanelField:queryItem←numberItem)
          (numberItem:jobPanelField:visibleFlg←T)
          (WINDOWPROP w 'NumberOfCopies numberItem:jobPanelField)
          (padMenu:MENUPOSITION← (create POSITION
					 XCOORD ← (
					numberItem:itemRegion:LEFT+numberItem:itemRegion:WIDTH+10)
					 YCOORD ← (yPos-padMenu:IMAGEHEIGHT)))
          (ADDMENU padMenu w)
          (DSPFONT font WindowTitleDisplayStream)
          (MOVETO 0 padMenu:MENUGRID:REGION.BOTTOM-5 w)
          (WINDOWPROP w 'SelectableItems < ! (WINDOWPROP w 'SelectableItems)
					   ! (for f in CopiesFields
						join (CreateFieldItems f copyJob w 5))
					   >)
          (printout w .SKIP 4)
          (ADDMENU [create MENU
			   MENUFONT ← Gacha12Bold
			   ITEMS ← '("" % HELP%  "")
			   WHENSELECTEDFN ← (FUNCTION (LAMBDA (item menu)
			       (HelpFromPanel (WFROMMENU menu]
		   w
		   (create POSITION
			   XCOORD ← 400
			   YCOORD ← (DSPYPOSITION NIL w)))
          (ADDMENU [create MENU
			   MENUFONT ← Gacha12Bold
			   ITEMS ← '("" PROCEED "")
			   WHENSELECTEDFN ← (FUNCTION (LAMBDA (item menu)
			       (ProceedFromPanel (WFROMMENU menu]
		   w
		   (create POSITION
			   XCOORD ← 160
			   YCOORD ← (DSPYPOSITION NIL w)))
          (WINDOWPROP w 'BUTTONEVENTFN (FUNCTION JobPanelButtonHandler))
          (WINDOWPROP w 'SelectableQueryItems (for f in CopyJobFields when jpField← (WINDOWPROP
									     w f)
						 collect jpField:queryItem))
          (RETURN w])

(JobFieldValue
  [LAMBDA (field job)                                        (* edited: " 7-FEB-83 12:40")
                                                             (* Fetch the value of field in job.)
    (SELECTQ field
	     (#OfCopySheets job:#OfCopySheets)
	     (#OfOriginalSheets job:#OfOriginalSheets)
	     (Collate job:Collate)
	     (CopiesOnStandardPaper job:CopiesOnStandardPaper)
	     (CopiesTooThickToStaple job:CopiesTooThickToStaple)
	     (CopyBrightness job:CopyBrightness)
	     (InputProcessor job:InputProcessor)
	     (NumberOfCopies job:NumberOfCopies)
	     (OriginalTooThick job:OriginalTooThick)
	     (OriginalsBound job:OriginalsBound)
	     (OriginalsOnStandardPaper job:OriginalsOnStandardPaper)
	     (OriginalsPaperTooFragileOrThick job:OriginalsPaperTooFragileOrThick)
	     (OriginalsStandardSize job:OriginalsStandardSize)
	     (OriginalsTooLarge job:OriginalsTooLarge)
	     (OriginalsTooSmall job:OriginalsTooSmall)
	     (Reduction job:CopyJob.Reduction)
	     (Staple job:Staple)
	     (TwoSidedCopies job:TwoSidedCopies)
	     (TwoSidedOriginals job:TwoSidedOriginals)
	     (Unbindable job:Unbindable)
	     (RECORDACCESS field job CopyJobRecord])

(JobPanelButtonHandler
  [LAMBDA (window)                                           (* edited: " 6-FEB-83 20:05")
                                                             (* selects a SelectableItem from the window.
							     If there is an item selected already, it is deselected.)
    (PROG [now previous oldValue cursor (SelectableItems (WINDOWPROP window (QUOTE SelectableItems)))
	       (reg (WINDOWPROP window (QUOTE REGION]
          (while (LASTMOUSESTATE (OR LEFT MIDDLE)) and (INSIDE? reg LASTMOUSEX LASTMOUSEY)
	     do (TOTOPW window)
		(MENUBUTTONFN window)
		(now←(InItem? SelectableItems (CURSORPOSITION NIL window)))
		(if now and ~previous
		    then previous←now:jobPanelField:selectedItem)
		(if previous and previous~=now
		    then (DeselectItem previous window)
			 oldValue←(JobFieldValue previous:jobPanelField:JobPanelField.field
						 (WINDOWPROP window (QUOTE CopyJob)))
			 (if oldValue and (~now or now:jobPanelField~=previous:jobPanelField)
			     then (SelectItem (for i in previous:jobPanelField:valueItems
						 thereis i:itemValue=oldValue)
					      window)))
		(if now and now~=previous
		    then (SelectItem now window))
		(previous←now)
		(GETMOUSESTATE))
          (if now
	      then cursor←(CURSOR WAITINGCURSOR)
		   (UpdateJobField (WINDOWPROP window (QUOTE CopyJob))
				   now:jobPanelField:JobPanelField.field now:itemValue)
		   (CURSOR cursor))
          (RETURN])

(JobPanelHelpHandler
  [LAMBDA (window)                                           (* edited: " 6-FEB-83 20:10")
                                                             (* selects a SelectableItem from the window.
							     If there is an item selected already, it is deselected.)
    (PROG [now previous oldValue (SelectableItems (WINDOWPROP window (QUOTE SelectableQueryItems)))
	       (reg (WINDOWPROP window (QUOTE REGION)))
	       (relevantFields (fetch relevantFields of (WINDOWPROP window (QUOTE CopyJob]
          (while (LASTMOUSESTATE (OR LEFT MIDDLE)) and (INSIDE? reg LASTMOUSEX LASTMOUSEY)
	     do (TOTOPW window)
		(now←(InItem? SelectableItems (CURSORPOSITION NIL window)))
		(now←(if now and now:jobPanelField:JobPanelField.field MEMB relevantFields
			 then now))
		(if previous and previous~=now
		    then (FlipItem previous window))
		(if now and now~=previous and ~(now : invertedFlg)
		    then (FlipItem now window))
		(previous←now)
		(GETMOUSESTATE))
          (if now
	      then (GiveUserQueryHelp (WINDOWPROP window (QUOTE CopyJob))
				      now:jobPanelField:JobPanelField.field now))
          (RETURN])

(PrintAndBox
  [LAMBDA (exp window indentation)                           (* edited: "20-SEP-83 22:18")
                                                             (* Indents indentation spaces, prints exp on window, and
							     returns the box taken by the characters.)
    (PROG (left dsfont)
          (SPACES (OR indentation 0)
		  window)
          (left←(DSPXPOSITION NIL window))
          (DSPRIGHTMARGIN 50000 window)                      (* so that it won't auto carrage return.
							     This should be resetsaved.)
          (PRIN1 exp window)
          (dsfont←(DSPFONT NIL window))
          (RETURN (create REGION
			  LEFT ← left
			  BOTTOM ←(IDIFFERENCE (DSPYPOSITION NIL window)
					       (FONTPROP dsfont (QUOTE DESCENT)))
			  HEIGHT ←(FONTPROP dsfont (QUOTE HEIGHT))
			  WIDTH ←((DSPXPOSITION NIL window)
			   -left])

(PrintComment
  [LAMBDA (text dontClearFlg)                                (* edited: "14-JAN-83 13:35")

          (* Print the text in the comment window. Clear the window first when dontClearFlg is NIL. text can be text for a 
	  paragraph or a paragraph.)


    (if ~dontClearFlg
	then (CLEARW CommentWindow))
    (PrintParagraph CommentWindow (if (type? Paragraph text)
				      then text
				    else (create Paragraph
						 text ← text])

(ProceedFromPanel
  [LAMBDA (panel)                                            (* JG "29-Jan-84 20:14")
                                                             (* Respond to the user pushing the "PROCEED" button on 
							     the job description panel.)
    (PROG [planGenerator unvaluedFields plan (job (WINDOWPROP panel 'CopyJob]
          (SETQ unvaluedFields (for f in (fetch relevantFields of job) unless (JobFieldValue f job)
				  collect f))
          (RETURN (COND
		    [unvaluedFields (PrintComment '(Answer the indicated questions.))
				    (for f in unvaluedFields do (AND (WINDOWPROP panel f)
                                                             (* *JG Skip fields like InputProcessor which do not have
							     a JobPanelField)
								     (FlashQuery job f]
		    (T [SETQ planGenerator (OR (fetch planGenerator of job)
					       (ResolveNewJobValue job 'NumberOfCopies
								   (fetch (CopyJob NumberOfCopies)
								      of job]
		       (COND
			 [(AND planGenerator (fetch generator of planGenerator))
			   (\TraceIt BluebonnetTrace "Create Procedure for Job.")
			   (SETQ plan (APPLY* (fetch generator of planGenerator)
					      job))
			   (COND
			     ((type? Plan plan)
			       (\TraceIt BluebonnetTrace "Perform the procedure.")
			       (replace (CopyJob plan) of job with plan)
			       (CLOSEW (fetch descriptionPanel of CopyJob))
			       (CLOSEW CommentWindow)
			       (SPAWN.MOUSE)
			       (DoPlan plan job)
			       (CLOSEW UserInstructionWindow)
			       (CLOSEW StatusWindow)         (* HelpWindow is NIL if the Help System is not 
							     loaded...)
			       (COND
				 (HelpWindow (CLOSEW HelpWindow)))
			       (COND
				 (HelpWindow (DELETEMENU (WINDOWPROP HelpWindow 'HelpMenu)
							 T)))
			       (DELETEMENU (CAR (WINDOWPROP Simulate8200Menu 'MENU))
					   T)
			       (StartBluebonnet)
			       (CARET T]
			 (T (PrintComment '(Bluebonnet does not have a procedure for doing the job 
						       you described. Please check the job 
						       description
							 and try again.])

(RedisplayJobPanelField
  [LAMBDA (jpField window)                                   (* edited: " 2-FEB-83 10:55")
                                                             (* Redisplay in window the query and values for the 
							     given job panel field.)
    (if jpField and [~(jpField : visibleFlg) or jpField:queryItem:invertedFlg
			or ~(jpField : selectedItem) and (JobFieldValue jpField:JobPanelField.field
									(WINDOWPROP window
										    (QUOTE CopyJob]
	then (PROG [[fieldValue (JobFieldValue jpField:JobPanelField.field (WINDOWPROP window
										       (QUOTE CopyJob]
		    (region (jpField:queryItem:itemRegion))
		    (fontDescent (FONTPROP (DSPFONT NIL window)
					   (QUOTE DESCENT]
	           (MOVETO region:LEFT region:BOTTOM+fontDescent window)
	           (printout window (GETPROP jpField:JobPanelField.field (QUOTE query)))
	           (jpField:queryItem:invertedFlg←NIL)
	           (jpField:selectedItem←NIL)
	           (for item in jpField:valueItems
		      do (region←item:itemRegion)
			 (MOVETO region:LEFT region:BOTTOM+fontDescent window)
			 (printout window item:itemValue)
			 (if item:itemValue=fieldValue
			     then (SelectItem item window)))
	           (jpField:visibleFlg←T])

(RedisplayMenu
  [LAMBDA (menu window)                                      (* ref: " 1-JUN-82 14:23")
                                                             (* Redisplay menu in window.)
    (PROG ((x (menu:MENU.MENUGRID:REGION.LEFT))
	   (y (menu:MENU.MENUGRID:REGION.BOTTOM)))
          (UPDATE/MENU/IMAGE menu)
          (menu:MENUGRID:REGION.LEFT←x)
          (menu:MENUGRID:REGION.BOTTOM←y)
          (BLTMENUIMAGE menu (WINDOWPROP window 'DSP])

(RedisplayMenuTitle
  [LAMBDA (menu title font)                                  (* edited: " 1-FEB-83 13:02")
                                                             (* Redisplay the menu with the new title in the given 
							     font. Return title.)
    (PROG ((oldFont (DSPFONT font WindowTitleDisplayStream)))
          (menu:MENU.TITLE←title)
          (RedisplayMenu menu (WFROMMENU menu))
          (DSPFONT oldFont WindowTitleDisplayStream)
          (RETURN title])

(RefreshPanel
  [LAMBDA NIL                                                (* ref: "10-JUN-82 14:32")
                                                             (* Redisplay the relevant queries for CopyJob's 
							     description panel.)
    (UpdateJobDescriptionPanel CopyJob:descriptionPanel T])

(RelevantField?
  [LAMBDA (field job)                                        (* edited: "18-JAN-83 17:34")
                                                             (* Determine whether field is relevant in job.)
    (field MEMB job:relevantFields])

(RemoveDerivationsOf
  [LAMBDA (field job)                                        (* ref: " 9-JUN-82 10:51")
                                                             (* Remove all derivations from job that have field as 
							     their result field. Return the new list of derivations.)
    job:derivations←(for d in job:derivations unless d:resultField=field collect d])

(RemoveValue
  [LAMBDA (field job)                                        (* edited: " 4-FEB-83 13:26")
                                                             (* Remove the current value of field from job.
							     Also, remove any values derived using the removed value.
							     Return the removed value.)
    (PROG ((value (JobFieldValue field job)))
          (if value
	      then (SetJobField job field)
		   (RemoveDerivationsOf field job)
		   (for d in (for d1 in job:derivations when field MEMB d1:givens collect d1)
		      do (RemoveValue d:resultField job)))
          (RETURN value])

(ResolveNewJobValue
  [LAMBDA (job field value)                                  (* edited: "10-MAR-83 13:45")

          (* A new value has been assigned to a field of a copy job via the job description panel. Make values of all fields
	  that were relevant before assignment of the new value be assertions, and remove any underived values of irrelevant
	  fields. Check on enabled plan generators and attempt to derive values for the fields relevant to that check and 
	  for those fields that are parameters to any enabled generators. Assign those fields as relevant and any that 
	  supported the attempted derivations. If all the relevant fields have values, and no generator is enabled, then 
	  apply any applicable help units. Before returning, assign previous values or default values to unvalued fields 
	  that became relevant after the assignment of the new value. Return a list of the currently enabled generators.)


    (PROG (dList consistent? gens unprocessedFields (newValue? T)
		 relevantFields)
          (for f in CopyJobFields do (if (RelevantField? f job)
					 then (AddAssertion job f (JobFieldValue f job))
				       elseif ~(DerivedResult? f job)
					 then (if (JobFieldValue f job)
						  then (LISTPUT job:removedAssertions f
								(JobFieldValue f job)))
					      (RemoveValue f job)))
          (AddAssertion job field value)
          (gens←(DeriveValuesForGenerators job))
          (for gen in gens:1 do (\TraceIt BluebonnetTrace "Procedure " gen:generator " enabled."))
          (job:relevantFields←gens::1)
          (CLEARW CommentWindow)
          (generator←(job:planGenerator←(SelectPlanGenerator gens:1)))
          (if generator
	      then (ShowTimeEstimate generator job)
		   (if generator:advisor
		       then (APPLY* generator:advisor job))
	    elseif (for f in gens::1 always (JobFieldValue f job))
	      then (ApplyHelpUnits job))
          (RETURN job:planGenerator])

(SecondsToRoundedMinutes
  [LAMBDA (seconds)                                          (* edited: " 1-FEB-83 15:29")
                                                             (* Convert seconds to minutes and round off the result.)
    (FIX seconds/60.0+.5])

(SelectItem
  [LAMBDA (item window)                                      (* ref: "26-MAY-82 15:58")
                                                             (* selects an item in window)
    (if item and item:jobPanelField:selectedItem~=item
	then (FlipItem item window)
	     item:jobPanelField:selectedItem←item])

(SelectPlanGenerator
  [LAMBDA (generators)                                       (* edited: " 1-FEB-83 13:18")
                                                             (* Select a generator from generators and return it.
							     If there is an obviously faster one, then select it.
							     Otherwise, ask the user.)
                                                             (* Dummy definition for now.)
    generators:1])

(SetJobField
  [LAMBDA (job field value)                                  (* edited: " 4-FEB-83 13:26")
                                                             (* Set the value of field in copy job)
    (RECORDACCESS field job CopyJobRecord (QUOTE replace)
		  value])

(ShowTimeEstimate
  [LAMBDA (generator job)                                    (* edited: " 4-MAR-83 16:49")
                                                             (* Print a time estimate for the plan to be produced by 
							     the generator in the comment window.)
    (PROG [hours (time (MAX 1 (SecondsToRoundedMinutes job:timeEstimate←(GeneratorsTimeEstimate
							 generator job]
          [PrintComment (BQUOTE (The currently described job will take about ,@
				     [COND
				       ((ILESSP time 60)
					 (LIST time))
				       (T (BQUOTE (, (SETQ hours (IQUOTIENT time 60))
						     ,
						     (COND
						       ((EQ hours 1)
							 (QUOTE hour))
						       (T (QUOTE hours)))
						     and , (IREMAINDER time 60]
				     ,
				     (COND
				       ((EQ time 1)
					 (QUOTE minute.))
				       ((IGREATERP time 60)
					 (QUOTE minutes!))
				       (T (QUOTE minutes.]
          (printout CommentWindow T T])

(Subset?
  [LAMBDA (x y)                                              (* edited: "19-JAN-83 15:59")
                                                             (* Test whether list x is a subset of list y.)
    (for xi in x always xi MEMB y])

(SupportsForDerivation
  [LAMBDA (field job)                                        (* edited: " 4-FEB-83 13:27")

          (* Return the list of fields that supports the value of field in job. Return NIL if the field has no value.
	  The field supports itself if it is an assertion.)


    (if (JobFieldValue field job)
	then (for d in job:derivations when d:resultField=field join (for g in d:givens
									join (SupportsForDerivation
									       g job)))
	       or <field>])

(TimeEstimateForJob
  [LAMBDA (job)                                              (* edited: "14-MAR-83 12:23")

          (* Return a time estimate for the job. Do so by determining an enabled generator for the job and calling its time 
	  estimating function. If no generators are enabled, return NIL.)


    (PROG (bestTime time (gens (DeriveValuesForGenerators job)))
          (for gen in gens:1
	     do (time←(GeneratorsTimeEstimate gen job))
		(if ~bestTime or time lt bestTime
		    then bestTime←time))
          (RETURN (OR bestTime 0])

(TimeFor1To1
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 11:38")
                                                             (* Time estimator for Plan1To1.)
    (TimeForPlanners [BQUOTE (MakeReady SetPanel LoadRDH MakeCopies UnloadRdh UnloadOutputTray 
					SayThankUser ,@ (COND
					  ((EQ (fetch CopiesOnStandardPaper of job)
					       (QUOTE No))
					    (QUOTE (LoadTopPaperTray UnloadTopPaperTray 
								     SelectBottomTray]
		     job])

(TimeFor1To2
  [LAMBDA (job)                                              (* edited: " 4-FEB-83 16:01")
                                                             (* Time estimator for Plan1To2.)
    (TimeForPlanners [BQUOTE (MakeReady SetPanel ReverseOriginals LoadRDH MakeCopies ReverseOriginals 
					TransferToTopTray MakeCopies UnloadOutputTray SayThankYou ,@
					(COND
					  ((EQ (fetch CopiesOnStandardPaper of job)
					       (QUOTE No))
					    (QUOTE (LoadTopPaperTray UnloadTopPaperTray 
								     SelectBottomTray]
		     job])

(TimeFor2To1WithMaster
  [LAMBDA NIL                                                (* edited: "11-MAR-83 13:50")
    0])

(TimeForBdaNoMaster
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 12:21")
                                                             (* Time estimator for PlanBdaNoMaster.)
    (PROG1 5                                                 (* Pull BDA latch and raise the RDH.))+(
      TIMES job:#OfOriginalSheets (PROG1 3                   (* Place original on glass and close cover.)
					 )+(PROG1 1          (* Press Start.))+(PROG1 13 
                                                             (* Copier overhead.))+(PROG1
	      (TIMES job:NumberOfCopies .8)                  (* Making the copies.)
	      )+(PROG1 2                                     (* Open cover and remove original.)))+(
      PROG1 5                                                (* Close the RDH.))+(PROG1 2 
                                                             (* Unload the output tray.))+(
      TimeForPlanners [BQUOTE (MakeReady SetPanel SayThankYou ,@ (COND
					   ((EQ (fetch CopiesOnStandardPaper of job)
						(QUOTE No))
					     (QUOTE (LoadTopPaperTray UnloadTopPaperTray 
								      SelectBottomTray]
		      job])

(TimeForBdaWithMaster
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 12:20")
                                                             (* Time estimator for PlanBdaWithMaster.)
    (PROG ((subJob1 (CopyCopyJob job))
	   (subJob2 (CopyCopyJob job)))
          (subJob1:CopiesOnStandardPaper←(QUOTE Yes))
          (subJob1:NumberOfCopies←1)
          (subJob1:TwoSidedCopies←(QUOTE No))
          (subJob1:Staple←(QUOTE No))
          (subJob2:CopyBrightness←(QUOTE normal))
          (subJob2:InputProcessor←(QUOTE RDH))
          (subJob2:NumberOfCopies←(if job:CopiesOnStandardPaper=(QUOTE Yes) and job:Staple=(QUOTE
										  No)
					and job:TwoSidedCopies=(QUOTE No)
				      then job:NumberOfCopies-1
				    else job:NumberOfCopies))
          (subJob2:OriginalsBound←(QUOTE No))
          (subJob2:OriginalsOnStandardPaper←(QUOTE Yes))
          (subJob2:OriginalsStandardSize←(QUOTE Yes))
          (subJob2:CopyJob.Reduction←(QUOTE FullSize))
          (subJob2:TwoSidedOriginals←(QUOTE No))
          (RETURN (PROG1 5                                   (* Connect step.))+(TimeForBdaNoMaster
		    subJob1)+(TimeEstimateForJob subJob2)+(-(TimeForPlanners (QUOTE (SayThankYou])

(TimeForPlanners
  [LAMBDA (planners job)                                     (* edited: " 1-FEB-83 16:24")

          (* Determine a time estimate for doing all the steps produced by planners on job. Planners is a list of atoms that
	  have timeEstimate properties. If the property is NIL, assume 0.0 If the property is an integer, assume that many 
	  seconds. If the property is an atom, call that function with the job as an argument.)


    (for p in planners bind time
       sum (time←(GETPROP p (QUOTE timeEstimate)))
	   (if time
	       then (if (FIXP time)
			then time
		      else (APPLY* time job))
	     else 0])

(TimeForTooThick
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 11:31")
                                                             (* Time estimator for PlanTooThick.)
    (PROG (sheetsPerSubjob #OfSubjobs (totalSheets (job:#OfOriginalSheets/(if job:TwoSidedOriginals=(
										QUOTE Yes)
									      then 2
									    else 1)))
			   (subjob (CopyCopyJob job)))
          (#OfSubjobs←(totalSheets+49)/50)
          (sheetsPerSubjob←totalSheets/#OfSubjobs)
          (subjob:#OfOriginalSheets←totalSheets/#OfSubjobs)
          (subjob:OriginalTooThick←(QUOTE No))
          (RETURN (PROG1 #OfSubjobs                          (* Divide originals into #OfSubjobs sections.)
			 )+(PROG1 #OfSubjobs*(TimeEstimateForJob subjob)
                                                             (* Do the subjobs.)
				  )+(PROG1 (if job:Collate
					       then #OfSubjobs*job:NumberOfCopies
					     else 0])

(TimeToCollate
  [LAMBDA (job)                                              (* edited: "16-MAR-83 11:55")
                                                             (* Estimate the time need to collate the copies for this
							     job by hand.)
    (if job:Collate=(QUOTE Yes)
	then (if ~(job:#OfCopySheets)
		 then (DeriveValue (QUOTE #OfCopySheets)
				   job))
	     job:NumberOfCopies*(job:#OfCopySheets or 2)
      else 0])

(TimeToReverseOriginals
  [LAMBDA (job)                                              (* edited: " 4-FEB-83 16:03")
                                                             (* The time estimating function to reverse a set of 
							     originals.)
    job:#OfOriginalSheets/(if job:TwoSidedOriginals=(QUOTE Yes)
			      then 2
			    else 1])

(TimeToStaple
  [LAMBDA (job)                                              (* edited: "16-MAR-83 11:54")
                                                             (* Time estimator for stapling the copies made in this 
							     job.)
    (if job:Staple=(QUOTE Yes)
	then 5+job:NumberOfCopies*3
      else 0])

(UpdateJobField
  [LAMBDA (job field value)                                  (* edited: "19-JAN-83 17:07")
                                                             (* Put the new values into the copy job and make the 
							     implied changes to the job description panel.)
    (ResolveNewJobValue job field value)
    (UpdateJobDescriptionPanel job:descriptionPanel])

(UpdateJobDescriptionPanel
  [LAMBDA (window refreshFlg)                                (* edited: " 1-FEB-83 15:17")
                                                             (* Redisplay relevant queries and erase all irrelevant 
							     queries. If refreshFlg is NIL, then redisplay only 
							     previously invisible relevant queries.)
    (for f in CopyJobFields bind [(job ←(WINDOWPROP window (QUOTE CopyJob]
       do (if (RelevantField? f job)
	      then (if refreshFlg
		       then (EraseJobPanelField (WINDOWPROP window f)
						window))
		   (RedisplayJobPanelField (WINDOWPROP window f)
					   window)
	    else (EraseJobPanelField (WINDOWPROP window f)
				     window))
       finally (if refreshFlg
		   then (RedisplayMenuTitle (WINDOWPROP window (QUOTE #OfOriginalSheetsMenu))
					    job:#OfOriginalSheets Gacha12Bold)
			(RedisplayMenuTitle (WINDOWPROP window (QUOTE NumberOfCopiesMenu))
					    job:NumberOfCopies Gacha12Bold])

(WhenNumberOfCopiesMenuSelected
  [LAMBDA (item menu)                                        (* edited: "16-MAR-83 12:51")
                                                             (* WhenSelectedFn for the numberOfCopies menu.)
    (WhenPadMenuSelected item menu (QUOTE NumberOfCopies)
			 (QUOTE NumberOfCopiesTimer])

(WhenOriginalsMenuSelected
  [LAMBDA (item menu)                                        (* edited: "16-MAR-83 13:06")
                                                             (* WhenSelectedFn for the #OfOriginals menu.)
    (WhenPadMenuSelected item menu (QUOTE #OfOriginalSheets)
			 (QUOTE NumberOfOriginalsTimer])

(WhenPadMenuSelected
  [LAMBDA (item menu field timerVar)                         (* edited: "16-MAR-83 12:56")
                                                             (* WhenSelectedFn for a number pad menu for field.)
    (if item~= ""
	then (PROG [cursor (job (WINDOWPROP (WFROMMENU menu)
					    (QUOTE CopyJob]
	           (RedisplayMenuTitle menu (if item=(QUOTE Clear)
						then 0
					      elseif (GREATERP (ABS (CLOCK 0)
								    -(EVAL timerVar))/1000.0 30)
						then item
					      else menu:MENU.TITLE*10+item)
				       Gacha12Bold)
	           (if menu:MENU.TITLE=0
		       then (UpdateJobDescriptionPanel job:descriptionPanel)
		     else cursor←(CURSOR WAITINGCURSOR)
			  (UpdateJobField job field menu:MENU.TITLE)
			  (CURSOR cursor))
	           (SET timerVar (CLOCK 0])
)
(DECLARE: EVAL@COMPILE 
(LOADCOMP? 'LOADBLUEBONNET)
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2968 52332 (AddAssertion 2978 . 3566) (AddDerivation 3568 . 4329) (Advise1To2 4331 . 
4607) (Advise2To1WithMaster 4609 . 4739) (AdviseBdaWithMaster 4741 . 6602) (ApplyHelpUnits 6604 . 7271
) (CommentOnJob 7273 . 7695) (CopyCopyJob 7697 . 8195) (CopyingTime 8197 . 8479) (CreateFieldItems 
8481 . 9696) (DefineDefaultJob 9698 . 10605) (DeriveValue 10607 . 12946) (DeriveValuesForGenerators 
12948 . 15850) (DerivedResult? 15852 . 16233) (DeselectItem 16235 . 16583) (EraseJobPanelField 16585
 . 17023) (FindEnabledGenerators 17025 . 17705) (FlashQuery 17707 . 18192) (FlipItem 18194 . 18480) (
FlipRegion 18482 . 18772) (GeneratorsTimeEstimate 18774 . 19160) (GetGeneratorParameters 19162 . 19460
) (GiveUserQueryHelp 19462 . 19917) (HelpFromPanel 19919 . 20300) (InItem? 20302 . 20605) (
InitiateDescriptionPanel 20607 . 25236) (JobFieldValue 25238 . 26442) (JobPanelButtonHandler 26444 . 
27988) (JobPanelHelpHandler 27990 . 29237) (PrintAndBox 29239 . 30117) (PrintComment 30119 . 30609) (
ProceedFromPanel 30611 . 32842) (RedisplayJobPanelField 32844 . 34159) (RedisplayMenu 34161 . 34630) (
RedisplayMenuTitle 34632 . 35134) (RefreshPanel 35136 . 35459) (RelevantField? 35461 . 35729) (
RemoveDerivationsOf 35731 . 36141) (RemoveValue 36143 . 36828) (ResolveNewJobValue 36830 . 38931) (
SecondsToRoundedMinutes 38933 . 39205) (SelectItem 39207 . 39554) (SelectPlanGenerator 39556 . 40018) 
(SetJobField 40020 . 40305) (ShowTimeEstimate 40307 . 41288) (Subset? 41290 . 41561) (
SupportsForDerivation 41563 . 42108) (TimeEstimateForJob 42110 . 42708) (TimeFor1To1 42710 . 43225) (
TimeFor1To2 43227 . 43799) (TimeFor2To1WithMaster 43801 . 43930) (TimeForBdaNoMaster 43932 . 45150) (
TimeForBdaWithMaster 45152 . 46436) (TimeForPlanners 46438 . 47125) (TimeForTooThick 47127 . 48125) (
TimeToCollate 48127 . 48600) (TimeToReverseOriginals 48602 . 48978) (TimeToStaple 48980 . 49322) (
UpdateJobField 49324 . 49723) (UpdateJobDescriptionPanel 49725 . 50780) (
WhenNumberOfCopiesMenuSelected 50782 . 51120) (WhenOriginalsMenuSelected 51122 . 51459) (
WhenPadMenuSelected 51461 . 52330)))))
STOP