#! /bin/csh -f

#
# splitstr -- splits the argument string with spaces
#
# Original Author: Doug Greve
# CVS Revision Info:
#    $Author: nicks $
#    $Date: 2007/01/09 22:41:18 $
#    $Revision: 1.2 $
#
# Copyright (C) 2002-2007,
# The General Hospital Corporation (Boston, MA). 
# All rights reserved.
#
# Distribution, usage and copying of this software is covered under the
# terms found in the License Agreement file named 'COPYING' found in the
# FreeSurfer source code root directory, and duplicated here:
# https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferOpenSourceLicense
#
# General inquiries: freesurfer@nmr.mgh.harvard.edu
# Bug reports: analysis-bugs@nmr.mgh.harvard.edu
#


set VER = '$Id: splitstr,v 1.2 2007/01/09 22:41:18 nicks Exp $';

if($#argv != 1) then
  echo "USAGE splitstr string"
  echo "  version: $VER"
  exit 1;
endif

set orig  = `basename $argv[1]`;
set fname = $orig
set lenf  = `echo $fname | awk '{print length($1)}'`;
set splt  = ();
@ n = 1;
while($#splt < $lenf)
  set c = `printf %c $fname`;
  set splt = ($splt $c);
  @ n = $n + 1;
  set fname = `echo $fname | sed s/$c//`;
end

echo $splt

exit 0;
#########################################
