ex15.tcl

来自「很不错的tcl编程实例」· TCL 代码 · 共 58 行

TCL
58
字号
# Copyright 1996


# Authors

# Lakshmi Sastry
# Computing and Information Systems Department
# Rutherford Appleton Laboratory, Chilton, Didcot. OX11 0QX
# lakshmi.sastry@rl.ac.uk

#                         and

# Venkat VSS Sastry
# Department of Applied Mathematics and Operational Research
# Cranfield University, RMCS Shrivenham, Swindon, SN6 8LA
# sastry@rmcs.cran.ac.uk

# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
# fee is hereby granted, provided that this copyright
# notice appears in all copies.
  
# The authors, RAL, RMCS Shrivenham, Cranfield University and AGOCG
# make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without
# express or implied warranty. Likewise they accept no responsibility
# whatsoever for any public domain software modules used (which are
# hereby acknowledged) in this software 

set str1 {Good Morning!}
set str2 {Good Afternoon!}
#
# make up the command
#
set cmd {puts $tout $str1}
set cmd2 {puts $tout $str2}
#
# invoke appropriate command depending upon the time of the day
#
set dt [exec date]
#
# dt is a list. 3rd element contains time info. extract it
#
set t [lindex $dt 3]
#
# typical value for t is 11:32:24. Extract hours using split
# and pick up the first element
#
set hr [lindex [split $t :] 0]
#
# now choose appropriate salutation
#
if { $hr <= 12 } {
         eval $cmd
} else {
         eval $cmd2
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?