home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / Tickle-4.0.sit.hqx / Tickle-4.0 / library / arrayprocs.tcl next >
Text File  |  1993-10-26  |  1KB  |  36 lines

  1. #
  2. # arrayprocs.tcl --
  3. #
  4. # Extended Tcl array procedures.
  5. #------------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: arrayprocs.tcl,v 2.1 1993/04/07 02:42:32 markd Exp $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. #@package: TclX-ArrayProcedures for_array_keys
  20.  
  21. proc for_array_keys {varName arrayName codeFragment} {
  22.     upvar $varName enumVar $arrayName enumArray
  23.  
  24.     if ![info exists enumArray] {
  25.     error "\"$arrayName\" isn't an array"
  26.     }
  27.  
  28.     set searchId [array startsearch enumArray]
  29.     while {[array anymore enumArray $searchId]} {
  30.     set enumVar [array nextelement enumArray $searchId]
  31.     uplevel $codeFragment
  32.     }
  33.     array donesearch enumArray $searchId
  34. }
  35.