In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
The principle analysis of define_proc_attributes and parse_proc_arguments, aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The define_proc_attributes and parse_proc_arguments commands can extend the functions of proc in the tcl language and create commands with the same help and attributes as the Synopsys command. When you create a new proc, it has the following inherent properties:
You can use the info body command to view the contents of the proc proc can be modified, the abbreviation of the proc name can be placed in the Procedures command group by using the define_proc_attributes command, you can
Specifies the help text of the command specifies whether the parameter rule prohibits viewing and modification whether to prohibit the abbreviation of the name specifies that command groupdefine_proc_attributes uses the define_proc_attributes command to define and change the properties of proc. The syntax is as follows: define_proc_attributes proc_name [- info info_text] [- define_args arg_defs] [- command_group group_name] [- hide_body] [- hidden] [- permanent] [- dont_abbrev] proc_name specifies the name of the proc
-info info_text specifies the help text to use with the help command or the-help option
-define_args arg_defs specifies the help text of the proc parameter and its properties
-permanent prevents proc from being modified
-dont_abbrev, no matter what the sh_command_abbrev_mode variable is set to, prevent the use of proc abbreviations
You can use the-define_args option to specify the help text for the parameters of the proc and define the data types and properties of the parameters.
The argument to-define_args is a list of lists. Each list element specifies the attributes of the proc parameter. Each list element has the following format: arg_name option_help value_help data_type attributesarg_name specifies the name of the proc parameter
Short description of the option_help parameter short description of the value_help parameter value data_type specify the data type of the parameter attributes other properties of the parameter define_proc_attributes Command Example
Proc plus {a b} {return [expr $a + $b]} define_proc_attributes plus\-info "Add two numbers"\-define_args {{a "first addend" a stringrequired}\ {b "second addend" b stringrequired}}
Dc_shell > help plusplus # Add two numbers
Dc_shell > help-verbose plusUsage: plus # Add two numbersa (first addend) b (second addend)
Dc_shell > plus 5 611
The parse_proc_argumentsparse_proc_arguments command parses parameters that are passed to proc using the define_proc_attributes command.
Typically, parse_proc_arguments is the first command called in proc to validate parameters. You cannot use the parse_proc_arguments command outside of proc. The syntax of parse_proc_arguments is
Parse_proc_arguments-args arg_list result_array
-args arg_list specifies the list of parameters passed to proc. Result_array specifies that the array stores parsed parameters.
The proc plus {args} # # keyword args represents a variable number of parameters {parse_proc_arguments-args $args results # # saves the parameter to an array named results, and the array element name is the parameter name The element value is the parameter value foreach argname [array names results] {echo "$results ($argname)"} define_proc_attributes plus\-info "echo two numbers"\-define_args {{a "first addend" a string required}\ {b "second addend" b string required}}
Plus shows the use of parse_proc_arguments. Plus accepts various types of parameters and prints them out. Dc_shell > plus a b a b can also be accessed through info body procedure_nameinfo args procedure_nameproc_body procedure_nameproc_args procedure_name
Print out the body and parameters of the proc respectively. If you do not use the parse_proc_arguments command, the proc will not respond to the-help option. However, you can always use the help command. This is the answer to the question about the principle analysis of define_proc_attributes and parse_proc_arguments. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.