通常の Tcl プロシージャと同様、ユーザー プロシージャの引数定義は、位置ベースにするか、args
変数を使用して引数の変数リストを指定します。
proc ::tclapp::mycompany::template::my_command2 { arg1 {optional1 ,} } {
…
}
または
proc ::tclapp::mycompany::template::my_command2 { args } {
…
}
どちらの場合でも、プロシージャで指定可能なコマンド ライン引数のリストをメタコメント Argument Usage
で正しく定義するのは、開発者の責任です。システムでは、メタコメント Argument Usage
からの引数のリストと実際に引数定義が一致しているかはチェックされません。
メタコメント Argument Usage
はヘルプ メッセージに使用されるので、プロシージャで引数を渡すのにどちらの形式を使用した場合でも、メタコメントをアップデートする必要があります。次に例を示します。
proc ::tclapp::mycompany::template::my_command2 { arg1 {optional1 ,} } {
# Summary : A one line summary of what this proc does
# Argument Usage:
# arg1 : A one line summary of this argument
# [optional1=,] : A one line summary of this argument
# Return Value:
# TCL_OK is returned with result set to a string
# Categories: xilinxtclstore, template
…
}
または
proc ::tclapp::mycompany::template::my_command2 { args } {
# Summary : A one line summary of what this proc does
# Argument Usage:
# arg1 : A one line summary of this argument
# [optional1=,] : A one line summary of this argument
# Return Value:
# TCL_OK is returned with result set to a string
# Categories: xilinxtclstore, template
…
}
注記: 可能な限り、位置ベースの引数ではなく
args
を使用してください。args
を使用した方が、コマンド ライン引数の順序に制限がないので、ユーザーが使用しやすいものとなります。プロシージャでサポートされるコマンド ライン引数が 1 つか 2 つのみの場合は、位置ベースの指定方法を使用できますが、引数の順序は決まっており、ユーザーにはどの順序で引数を指定すればよいかわからないので (ヘルプ システムではこの情報は含まれない)、ユーザーには使いにくいものとなります。