fork download
  1. proc example {first {second ""} args} {
  2. if {$second eq ""} {
  3. puts "There is only one argument and it is: $first"
  4. return 1
  5. } else {
  6. if {$args eq ""} {
  7. puts "There are two arguments - $first and $second"
  8. return 2
  9. } else {
  10. puts "There are many arguments - $first and $second and $args"
  11. return "many"
  12. }
  13. }
  14. }
  15.  
  16. set count1 [example ONE]
  17. set count2 [example ONE TWO]
  18. set count3 [example ONE TWO THREE ]
  19. set count4 [example ONE TWO THREE FOUR]
  20.  
  21. puts "The example was called with $count1, $count2, $count3, and $count4 Arguments"
  22.  
Success #stdin #stdout 0.02s 5272KB
stdin
Standard input is empty
stdout
There is only one argument and it is: ONE
There are two arguments - ONE and TWO
There are many arguments - ONE and TWO and THREE
There are many arguments - ONE and TWO and THREE FOUR
The example was called with 1, 2, many, and many Arguments