Index: trunk/ippTasks/dist.pro
===================================================================
--- trunk/ippTasks/dist.pro	(revision 27462)
+++ trunk/ippTasks/dist.pro	(revision 27561)
@@ -92,17 +92,42 @@
 end
 
+macro get.host.for.component
+    if ($0 != 3)
+        echo "USAGE: get.host.for.component (componentID) (varname)"
+        break
+    end
+    local component host varname
+    $component = $1
+    $varname = $2
+    substr $component 0 3 COMP_HEAD
+    if ("$COMP_HEAD" == "sky")
+        book getword ipphosts dist_skycell count -var count
+        local j myValue skyhash
+        list word -splitbychar . $component
+        $skyhash = 0
+        for j 0 $word:n
+            inthash $word:$j $count -var myValue
+            $skyhash = $skyhash + $myValue
+        end
+        inthash $skyhash $count -var skyhash
+        sprintf skyname "sky%02d" $skyhash
+        book getword ipphosts dist_skycell $skyname -var host
+    else
+        book getword ipphosts dist_chip $component -var host
+    end
+    $$varname = $host
+end
 
 macro set.dist.workdir.by.component
-    # component template default varname
-    if ($0 != 6)
-        echo "USAGE: set.workdir.by.component (stage_id) (componentID) (template) (default) (varname)"
+    if ($0 != 5)
+        echo "USAGE: set.workdir.by.component (stage_id) (componentID) (template) (varname)"
         break
     end
     local host stage_id component default template varname length start count selector component_id random_number
+
     $stage_id = $1
     $component = $2
     $template = $3
-    $default = $4
-    $varname = $5
+    $varname = $4
     if ("$template" == "NULL")
         echo "ERROR: WORKDIR template not set."
@@ -111,37 +136,31 @@
     book getword ipphosts distribution count -var count
     if ("$count" == "NULL")
-        echo "ERROR: disthosts is empty"
-        break
-    end
+        echo "ERROR: distributin hosts list is empty"
+        break
+    end
+    $host = "foo"
     if ("$component" == "exposure") 
-        $selector = $stage_id
+        # take last two letters of selector
+        # treat it as an integer and use modulous of length of distribution hosts
+        # to compute an index into the host table
+        strlen $stage_id length
+        $start = $length - 2
+        substr $stage_id $start 2 index
+        $component_id = $index % $count
+        book getword ipphosts distribution $component_id -var myhost
     else
-        $selector = $component
-    end
-    #echo selector is $selector
-    # take last two letters of selector
-    # treat it as an integer and use modulous of length of distribution hosts
-    # to compute an index into the host table
-    strlen $selector length
-    $start = $length - 2
-    substr $selector $start 2 index
-    $component_id = $index % $count
-
-    #echo component_id is $component_id
-
-    book getword ipphosts distribution $component_id -var host
-    if ("$host" == "NULL")
+        get.host.for.component $component myhost
+    end
+
+    if ("$myhost" == "NULL")
         echo "ERROR: failed to find host for $component"
-        $host = $default
-    end
-
-    #echo host is $host
-
-    strsub $template @HOST@ $host -var $varname
+        break
+    end
+
+    strsub $template @HOST@ $myhost -var $varname
 
     #echo template is $template
     #echo outdir is $$varname
 end
-
 
 
@@ -263,5 +282,5 @@
 
 
-    set.dist.workdir.by.component $DIST_STAGE_ID $COMPONENT $OUTDIR_TEMPLATE ipp047 OUTDIR 
+    set.dist.workdir.by.component $DIST_STAGE_ID $COMPONENT $OUTDIR_TEMPLATE OUTDIR 
     if ("$OUTDIR" == "NULL")
         echo ERROR failed to set workdir for $COMPONENT
