sky565k
06-12-2007, 06:08 PM
When I specify a command via –command for a button or slider or other UI element, there doesn’t seem to be a good way to use a variable as part of that command. The script I'm writing has a lot of procedurally created buttons, and I want to have them call a particular proc when they are pushed and pass a number to that proc. Namely, the number of that particular button. For example:
button -c "myProc($numButtons)";Where $numButtons is the number of buttons that exist so far. This doesn't work since when the button is pressed it is literally executing "myProc($numButtons)" instead of "myProc(4)" or whatever the number was, so it says $numButtons is undeclared. Using a global variable doesn't work either, since it will always pass myProc the CURRENT value of $numButtons and not whatever the value was when that particular button was created.
Is there any way around this?
button -c "myProc($numButtons)";Where $numButtons is the number of buttons that exist so far. This doesn't work since when the button is pressed it is literally executing "myProc($numButtons)" instead of "myProc(4)" or whatever the number was, so it says $numButtons is undeclared. Using a global variable doesn't work either, since it will always pass myProc the CURRENT value of $numButtons and not whatever the value was when that particular button was created.
Is there any way around this?
