function [numlegs] = getLegs(action,numlegsi)
% function [numlegs] = getLegs(action,info)
% action: get - return nlegs(info). if info 0, return nlegs.
% 	  set - set nlegs to info
%	  clear - clear nlegs, return []
% output ex: numlegs = [6], or if criss-cross, [6 4], or if qroute, [5 5 5 5],...
try,
persistent nlegs

numlegs = nlegs;
if strcmp(action,'get'),
	if (numlegsi == 0)
		numlegs = nlegs;
	else
		if isempty(nlegs), numlegs = nlegs; 
		else numlegs = nlegs(numlegsi); end
	end
elseif strcmp(action,'set'),
	nlegs = numlegsi;
elseif strcmp(action,'clear'),
	nlegs = [];
	numlegs = [];
end
catch, errorbox('getLegs failed'), end
