Index: mttroot/mtt/bin/trans/m/rbg2abg.m
==================================================================
--- mttroot/mtt/bin/trans/m/rbg2abg.m
+++ mttroot/mtt/bin/trans/m/rbg2abg.m
@@ -3,10 +3,14 @@
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % %% Version control history
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % %% $Id$
 % %% $Log$
+% %% Revision 1.13  1997/08/04 12:50:39  peterg
+% %% Many bug fixes to the named port version + tied up the logic and
+% %% supporting comments.
+% %%
 % %% Revision 1.12  1997/08/02 19:37:53  peterg
 % %% Now uses named ports.
 % %%
 % %% Revision 1.11  1997/04/29 09:12:37  peterg
 % %% Added error message if port label near to >1 bond.
@@ -170,50 +174,53 @@
 	% Find the port label on component end of bond (if any)
 	[port_index,m] = getindex(port_bond,b);
 	if m==1
 	  k=k+1;
 	  unsorted_port_list(k,:) = port_name(port_index,:);
-	  end;
-      end;
-     
-      %Either all or non ports should be labelled - write error
-      %message if this is not so
-      if (k~=0)&(k~=n_comp_ports)
-        mtt_info(['Component ', comp_name, ' (', comp_type, ') has wrong number of labels'], infofile); 
-        mtt_info(sprintf("\tit has %1.0f labels but should have 0 or %1.0f",k,n_comp_ports), infofile); 
-      end;
-
-      [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
-      if m_unsorted_ports<2
-        n_unsorted_ports = 0;
-      end;
-
-      unsorted_port_list
-
-
-      % One port defaults:
-      if n_comp_ports==1
-        if n_unsorted_ports==0
-          unsorted_port_list(1,:) = port_list(1,:);
-        end; 
-      end;
-      
-      % Junctions (order of ports unimportant)
-      if (comp_type=='zero')|(comp_type=='one')
-        for j = 1:n_comp_ports
-          components(i,j) = signed_bond_list(j);
-        end
-      else %Order of ports is important
-      %Write out the signed bond list in the correct order
-        for j = 1:n_comp_ports
-          name_k = unsorted_port_list(j,:);
-          k = name_in_list(name_k, port_list)
-          if k==0
-            mtt_info(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], infofile); 
-          else
-          components(i,j) = signed_bond_list(k);     
-          end;
+	end;
+      end;
+    else % just use that provided by the component
+      unsorted_port_list = port_list;
+      k = n_comp_ports;
+    end;
+
+    %Either all or non ports should be labelled - write error
+    %message if this is not so
+    if (k~=0)&(k~=n_comp_ports)
+      mtt_info(['Component ', comp_name, ' (', comp_type, ') has wrong number of labels'], infofile); 
+      mtt_info(sprintf("\tit has %1.0f labels but should have 0 or %1.0f",k,n_comp_ports), infofile); 
+    end;
+
+    [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
+    if m_unsorted_ports<2
+      n_unsorted_ports = 0;
+    end;
+
+    unsorted_port_list
+
+
+    % One port defaults:
+    if n_comp_ports==1
+      if n_unsorted_ports==0
+        unsorted_port_list(1,:) = port_list(1,:);
+      end; 
+    end;
+    
+    % Junctions (order of ports unimportant)
+    if (comp_type=='zero')|(comp_type=='one')
+      for j = 1:n_comp_ports
+        components(i,j) = signed_bond_list(j);
+      end
+    else %Order of ports is important
+    %Write out the signed bond list in the correct order
+      for j = 1:n_comp_ports
+        name_k = unsorted_port_list(j,:);
+        k = name_in_list(name_k, port_list)
+        if k==0
+          mtt_info(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], infofile); 
+        else
+          components(i,j) = signed_bond_list(k);     
         end;
       end;
     end;
   end;
 end;