Read.csh



#  Emulate the Bourne Shell's read command, which reads a line of
#  input, breaking it up into words, which are then assigned, one-by-
#  one, to the variables whose names are passed as arguments.  The
#  status code is set to 0 if successful or non-zero if end-of-file
#  was encountered.

#  Copyright (c) 1996 by Hamilton Laboratories.  All rights reserved.


proc read( Rvariables )
   local Rinput, Ri
   set input = $getline:x
   if (!eofgetline) then
      if ($#Rvariables) then
         echo `min` >nul   # Make sure the min proc is loaded
         for Ri = 0 to min($#Rvariables - 2, $#input - 1) do
            eval "@ $Rvariables[Ri] = input[Ri]"
         end
         if ($#input < $#Rvariables) then
            for Ri = Ri + 1 to $#Rvariables - 1 do
               eval set $Rvariables[Ri] =
            end
         else
            @ Ri++
            eval set $Rvariables[Ri] = ^$input:$Ri^*
         end
      end
      @ status = 0
   else
      for Ri = 0 to $#Rvariables - 1 do
         eval set $Rvariables[Ri] =
      end
      @ status = 38        # ERROR_HANDLE_EOF
   end
end

read $argv



Hamilton C shell | Free Updates | Free Demo Software | Win32 Training
Y2K | Customer Testimonials | On-line Hamilton C shell User Guide
Home | Email | Support | Company Profile | Distributors | Links



Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number 800. This page was last modified August 14, 2001.