Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the proper way to create hyphen arguments in TCL?

Status
Not open for further replies.

okhajut

Programmer
Feb 19, 2021
1
GB
OK lets say I want to be able to call a function like this:

myfunc -param_action_a param_1 param_2 param_3 -param_action_b param_1 -no_param_action_c -no_param_action_d

Now there might be complex interdependencies because:
1. Some actions are compulsory to be specified, maybe one of many or all of many need to be specified when myfunc is called
2. Some actions are optional in any case and myfunc can always be successful without them being specified
3. Some actions are optional but can only be specified when certain other option exists but not otherwise
4. Some actions cannot be specified when certain others are specified and doing so leads to error

5. Some actions need parameters
6. Some actions do not need parameters
7. Some actions have default parameters maybe some or all
8. Some actions have no default parameters
9. The parameters must be validated to ensure that their value is not invalid

Now I have found that there exists these things:
1. parse_args
2. argparse
3. cmdline
4. Just hack a way using arrays and lists

Now I cannot for the life of me figure out the proper way to do this which can satisfy all the above requirements. Only a "proper" solution can do that. I do not have a lot of time to compare and contrast the 4 methods above. Does TCL have a proper solution to the problem I have described? Maybe someone from the TCL creators group can guide me here.
 
Seems like you just need to pass a list to myfunc. Then you can parse the list within the procedure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top