【问题标题】:tcl/Itcl error: wrong # args: should be "itcl::class name { definition }"tcl/Itcl 错误:错误 # args:应该是“itcl::class name { definition }”
【发布时间】:2018-07-31 12:19:05
【问题描述】:

我目前正在学习Itcl语言(基于tcl语言) 我写了以下脚本。
该脚本正在实现一个驱动程序,该驱动程序应该获取 4 个参数并将它们存储在类实例的私有变量中

#!/bin/tclsh

package require Itcl

itcl::class driver {

    # private variables
    private variable bundle_id ""
    private variable scope ""
    private variable isSimulationModel ""
    private variable isX ""


    private method set_data_field {data_field_flag data_value} {
        switch -- $data_field_flag {
            -bundle {
                set bundle_id $data_value
                catch {unset bundle_id} 
                return
            }
            -scope {
                set scope $data_value
                catch {unset scope} 
                return
            }
            -isSimulationModel {
                set isSimulationModel $data_value
                catch {unset isSimulationModel} 
                return
            }
            -isX{
                set isX $data_value
                catch {unset isX} 
                return
            }
        }
        return
    }


    constructor {bundle hdl_path is_simulation_model is_x} {
        set_data_field -bundle $bundle
        set_data_field -scope $hdl_path
        set_data_field -isSimulationModel $is_simulation_model
        set_data_field -isX $is_x
 }

    destructor {}




} #* _DRIVER_ * #


driver d 1 2 3 4

当我尝试运行它时,我收到以下错误:

wrong # args: should be "itcl::class name { definition }"
while executing "itcl::class driver {

    # private variables
    private variable bundle_id ""
    private variable scope ""
    private variable isSimulationModel ""
    private v..."
(file "./driver.itcl" line 5)

谁能帮助我并告诉我我做错了什么,我得到了这个错误?

【问题讨论】:

    标签: tcl itcl


    【解决方案1】:

    内联 cmets 必须以分号开头:

    } ;#* _DRIVER_ * #
      ^
    

    就目前而言,看起来您正在使用 #* _DRIVER_ * # 作为 4 个额外参数(#*_DRIVER_*#)进行 itcl::class driver { ... } #* _DRIVER_ * #

    阅读更多关于 Tcl 对wiki 的评论。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多