【问题标题】:how to call a tcl file from another tcl file如何从另一个 tcl 文件调用一个 tcl 文件
【发布时间】:2017-11-28 06:29:06
【问题描述】:

我需要调用一个 tcl 文件,其中包含从另一个 tcl 文件中捕获图像的代码。

例如我的 image.tcl 文件代码如下:

proc image {}  { 

set time [clock format [clock seconds] -format %Y%m%d_%H%M%S]
   
exec ffmpeg -f dshow -s 1280x720 -i "video=Integrated Webcam" -benchmark c:/test/sample_$time.jpg
	
}
image

所以,我想从另一个名为 main.tcl 的 tcl 文件中调用这个 image.tcl 文件,所以 main.tcl 的代码可以如下:

proc a {}  { 

"c:/test/image.tcl"

"c:/test/video.tcl" 

"c:/test/live.tcl"
	
}
a

当我调用 main.tcl 时,上面的 tcl 脚本应该一个接一个地运行

对此的任何解决方案。添加代码作为答案。谢谢。

【问题讨论】:

    标签: windows ffmpeg tcl exec


    【解决方案1】:

    您需要使用source

    在 main.tcl 中,您将拥有:

    proc a {}  { 
        source "c:/test/image.tcl"
        source "c:/test/video.tcl" 
        source "c:/test/live.tcl"
    }
    a
    

    【讨论】:

    • 但是从 image.tcl 文件中调用 image 时要小心。如果您在 main.tcl 中再次调用 image,您可能会运行两次相同的操作。当您使用source 时,您将能够使用源文件中的 proc。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    相关资源
    最近更新 更多