Excellent question.
cmd is not an argument (you can't call a C:-function with arguments as a command on the command line). It is declared as a local variable to the function, which means that it will only be used within the routine and will disappear after the routine has finished. The most prominent reasons for using local variables are 1. not to hog memory and 2. not to interfer with other code loaded into the environment.
It's true that arguments appear in the same list as local variables and it takes a while to spot the difference. What you should be looking for is a slash that separates arguments and local vars. Arguments go to the left of the slash and locals go to the right. The rules are:
- No arguments and no local vars: slash is optional
- No arguments but local vars: slash definately needed
- Arguments but no local vars: slash is optional
- Arguments and local vars: slash definately needed
Many more of the variables in the routine - actually ALL of them - should be declared as local variables, i.e. added to the list on the right side of the slash. However, in order to give you a chance to inspect the variables while testing the routine, you can leave them as global. Afterwards, when the routine is free from errors, they should all be declared local.