如何在其他 tcl 脚本中运行 tcl 脚本? [英] How to run tcl script inside other tcl script?

查看:75
本文介绍了如何在其他 tcl 脚本中运行 tcl 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 tcl 脚本.我想在第一个脚本完成后运行第二个脚本.我该怎么做?

I have two tcl scripts. I want to run the second script when the first finished. How can I do it?

推荐答案

取决于你的真正意思.

一种方法是编写第三个(主")脚本

One way is to write a third ("master") script which would do

source /the/path/to/the/first.tcl
source /the/path/to/the/second.tcl

另一种方法是将上述示例中对 source 的第二个调用添加到第一个脚本的底部.

Another way is to just add the second call to source from the above example to the bottom of the first script.

对第一种方法的修正:如果要执行的脚本与主脚本位于同一目录中,则source它们的惯用方法是

Amendment to the first approach: if the scripts to be executed are located in the same directory as the master script, an idiomatic way to source them is

set where [file dirname [info script]]
source [file join $where first.tcl]
source [file join $where second.tcl]

无论当前进程的目录是什么以及项目目录位于何处,这种方式的采购都将起作用.

This way sourcing will work no matter what the current process's directory is and where the project directory is located.

这篇关于如何在其他 tcl 脚本中运行 tcl 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆