Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19912645
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类:

2007-06-30 14:49:01

§2    开始使用

本章主要在不同的操作系统平台上运行TclTk,涉及的命令有: Source,console,info.

Wish: windowing shell.

可以用在tcl的命令行使用source filename 导入文件.

      

 

#!/bin/sh
# Run wish from the users PATH \
exec wish -f "$0" ${1+"$@"}
 
优点:

1,
二进制文件的位置不需要填入,它可以在你的 shell 查找路径中的任何地方。

2,
突破了#!只有30个字符的限制

3,
shell, 2行是注释,3行不是.但是在tcl, \是连接符号,下一行依旧是注释.所以只有shell有机会执行第3.exec 语句导致 shell 停止处理而启动 tclsh 来重新处理整个脚本。当 tclsh启动时,因为第二行的反斜线导致第三行被作为第二行注释的一部分,它把所有三行都作为注释对待。

${1+"$@"}

${1+"$@"}  的意思是判断$1是否设置过也就是定义过如果设置就设"$@"
${1:+"$@"} 是判断是否空串如果不是空串那就设置"$@"

          Some shells expand "$@" like "" (a single empty argument) when there

are no arguments.  ${1+"$@"} correctly expands to no arguments on

those shells.
 
Example 2-4 The EchoArgs script
# Tcl script to echo command line arguments
puts "Program: $argv0"
puts "Number of arguments: $argc"
set i 0
foreach arg $argv {
   puts "Arg $i: $arg"
   incr i
}
 
Table 2-1. Wish command line options

-colormap new

Use a new private colormap. See page 624.

-display display

Use the specified X display. UNIX only.

-geometry geometry

The size and position of the window. See page 658.

-name name

Specify the Tk application name. See page 648.

-sync

Run X synchronously. UNIX only.

-use id

Use the window specified by id for the main window. See page 667.

-visual visual

Specify the visual for the main window. See page 624.

--

Terminate options to wish.

Table 2-2. Variables defined by tclsh and wish

argc

The number of command-line arguments.

argv

A list of the command-line arguments.

argv0

The name of the script being executed. If being used interactively, argv0 is the name of the shell program.

embed_args

The list of arguments in the tag. Tcl applets only. See page 314.

env

An array of the environment variables. See page 124.

tcl_interactive

True (one) if the tclsh is prompting for commands.

tcl_library

The script library directory.

tcl_patchLevel

Modified version number, e.g., 8.0b1.

tcl_platform

Array containing operating system information. See page 192.

tcl_prompt1

If defined, this is a command that outputs the prompt.

tcl_prompt2

If defined, this is a command that outputs the prompt if the current command is not yet complete.

tcl_version

Version number.

auto_path

The search path for script library directories. See page 172.

auto_index

A map from command name to a Tcl command that defines it.

auto_noload

If set, the library facility is disabled.

auto_noexec

If set, the auto execute facility is disabled.

geometry

(wish only). The value of the -geometry argument.

阅读(3997) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~