by About the author: Brent Welch ÕýÔÚ¿ª·¢www.scriptics.comÕ¾µã, °üÀ¨Ò»¸öTclÓйصÄͳһ×ÊÔ´¶¨Î»(Tcl×ÊÔ´ÖÐÐÄ)×¢ÊÍÊý¾Ý¿â ºÍTclPro²úÆ·µÄecommerce infrasturcture.ͬʱ,Ëû»¹ÔÚ¿ª·¢¼¸¸ö´óÐ굀 Tcl/Tk³ÌÐò,ÓÐÔËÐÐÓÚwww.scriptics.comÕ¾µãÉϵÄTcl Httpd web ·þÎñÆ÷, ÓÐExmh ÓʼþÓû§½çÃæºÍwebtk HTML ±à¼Æ÷.ÁíÍ⣬Ëû»¹±àдÁË <<ýʹÓà Tcl ºÍ Tk ÊìÁ·±à³Ì> >. Welch1982ÄêÔÚ¿ÆÂÞÀ¶àÖÝBoulder´óѧÓîÖ溽¿Õ¹¤³Ì רҵ»ñѧʿѧ룬1986ÄêÔÚ¼ÓÖÝBerkeley´óѧ¼ÆËã»úרҵ»ñ˶ʿѧ룬 1990ÄêÔÚ¼ÓÖÝBerkeley´óѧ¼ÆËã»úרҵ»ñ²©Ê¿Ñ§Î»¡£¿ªÊ¼£¬WelchÊÇÊ©ÀÖ¹«Ë¾ ÅÁÂå°¢¶ûÍÐÑо¿ÖÐÐĵÄÑо¿Ô±£¬Ñо¿·Ö²¼Ê½ÏµÍ³¡£ºóÀ´£¬Ëû¼ÓÈëÌ«Ñô΢ϵͳ ʵÑéÊÒ£¬³ÉΪTcl/TkС×é³ÉÔ±¡£Ëû»¹ÊÇÃÀ¹ú¼ÆËã»úлáºÍµçÆøºÍ µç×Ó¹¤³Ìʦлá³ÉÔ±¡£Ö÷Ò³µØÖ·£ºhttp://www.beedub.com/ Content: |
Abstract:
±¾ÎĽéÉÜÁËTclÓïÑÔµÄÓï·¨ºÍ»ù±¾ÄÚÈÝ.
×÷ΪһÖֽű¾ÓïÑÔ£¬Tcl¾ßÓмòµ¥µÄÓï·¨.
cmd arg arg arg
$foo
foo
.[clock seconds]
"some stuff"
{some stuff}
\
ÏÂÃæÊÇTclÖдòÓ¡µ±Ç°Ê±¼äµÄÃüÁî. ËüʹÓÃÁËÈýÌõTclÃüÁî : set
, clock
, ºÍ puts
. set
ÃüÁî¸ø±äÁ¿¸³Öµ. clock
ÃüÁîÉú³Éʱ¼äÖµ . puts
ÃüÁî´òÓ¡½á¹û.
set seconds [clock seconds] puts "The time is [clock format $seconds]"
×¢ÒâÔÚ¸ø±äÁ¿¸³ÖµÊ±²¢Î´Ê¹ÓÃ$·ûºÅ. Ö»ÓÐÔÚʹÓñäÁ¿Ê±²ÅʹÓÃ$·ûºÅ.ÔÚÉϸöÀý×ÓÖÐ, seconds
±äÁ¿²¢²»ÊDZØÐëµÄ. ÄãÄÜʹÓÃÒ»¾äÃüÁî´òÓ¡³öµ±Ç°Ê±¼ä:
puts "The time is [clock format [clock seconds]]"
Tcl½âÎöTclÓï·¨ÊÇͨ¹ýÒÔÏÂÈý²½: ²ÎÊý·Ö×é, ½á¹ûÌæ»»ºÍÃüÁî·ÖÅÉ.
puts
ÃüÁîµÄÒ»¸ö²ÎÊý.
$foo
µÄÖµÌæ»»ÁËfoo
, Óýá¹ûÌæ»»ÁËÀ¨ºÅÃüÁî. Ìæ»»ÊÇÔÚ·Ö×éÖ® ºó ºó½øÐеÄ. ÕâÖÖ´ÎÐòʹ ÌرðµÄÖµ²¢Î´Ê¹ÃüÁî½á¹¹±ä¸´ÔÓ.
ÏÂÃæÊÇÁíÒ»¸öÀý×Ó:
ÕâÀï, ´óÀ¨ºÅÓÃÀ´²ÎÊý·Ö×é, ²¢Ã»½øÐÐÈκÎÌæ»». TclÓï·¨½âÎöÖªµÀ
set i 0 while {$i < 10} { puts "$i squared = [expr $i*$i]" incr i }
while
ÃüÁîûÓÐÌرðµÄµØ·½,Ïó¶Ô´ýÆäËüÃüÁîÒ»Ñù. while
ÃüÁîµÄÖ´ÐгÌÐòÖªµÀµÚÒ»¸ö²ÎÊýÊDZí´ïʽ, µÚÒ»¸ö²ÎÊýÊǶà¸öTclÃüÁî . ´óÀ¨ºÅ°ÑËü·Ö³ÉÁ½¸ö²ÎÊý:Âß¼±í´ïʽ¿ØÖÆÑ»·,ÃüÁîÔÚÑ»·²¿·Ö .
ÎÒÃÇ¿´µ½ÁËÁ½¸öÊýѧ±í´ïʽ: Âß¼±È½ÏºÍ³Ë·¨¼ÆËã. whileÃüÁî×Ô¶¯¼ÆËãµÚÒ»¸ö²ÎÊýÖµ. ÔÚÆäËü³¡ºÏʱ,ÄãÒªÃ÷ȷʹÓà expr
ÃüÁîÀ´Ö´ÐÐÊýѧ¼ÆËã.
×îºó,Tclµ÷ÓóÌÐòÖ´Ðи´ÔӵŤ×÷. ÎÒÃÇ¿ÉÒÔ¿´µ½Tcl ʹÓà expr
ÃüÁîÀ´Ö´ÐÐÊýѧÔËËã, puts
ÃüÁîÀ´Ö´ÐÐÊä³ö¹¦ÄÜ, set
ÃüÁîÀ´¸ø±äÁ¿¸³Öµ. ÕâЩTclÃüÁî,ÊÇͨ¹ýÒÑÔÚTclÖÐ×¢²á µÄCÓïÑÔ³ÌÐòÀ´Ö´ÐеÄ. CÓïÑÔ³ÌÐòµ÷ÓÃTclÃüÁî´«À´µÄ×Ö·û´®²ÎÊý, È»ºó´«»Ø½á¹û×Ö·û´®. дCÓïÑÔ³ÌÐò²¢²»¸´ÔÓ, ¶øÇÒ¿ÉÒÔ×öÈκÎÊÂÇ飬°üÀ¨·ÃÎÊÊý¾Ý¿âºÍ½¨Á¢Í¼Ðνç Ãæ. TclÓïÑÔ, ²¢²»Çå³þÃüÁî»á×öʲô , ËüÖ»ÊǽøÐвÎÊý·Ö×é, ½á¹ûÌæ»»ºÍÃüÁî·ÖÅÉ .
ÕâÊÇÒ»¸ö½×³Ë³ÌÐò:
proc fac {x} { if {$x < 0} { error "Invalid argument $x: must be a positive integer" } elseif {$x <= 1} { return 1 } else { return [expr $x * [fac [expr $x-1]]] } }
ÖÐÎÄ·Ò룺
Webpages maintained by the LinuxFocus Editor team © Brent B. Welch LinuxFocus 1999 |
1999-09-27, generated by lfparser version 0.6