|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Way to change variable in a loop
Is there a way to loop and change the variable everytime if the variable only changes by a number for example
i = increasing increment variablename = Title + increament If I try Title+1 = value of course that doesn't work but is there a way? |
#2
|
||||
|
||||
I'm not entirely sure I understand the question, but it sounds like you're trying to assign to a different variable name each time through the loop. If that's correct, don't use separate variables; use an array that you can index using SetElement.
You can also use a case statement to do the assignment: Code:
If i > 1 var1 = value > 2 var2 = value ... A third option, which I hesitate to even mention for fear of abuse, is to assemble a statement in string form (e.g. "var" + i + " = value") and use EvaluateExpression to execute it. This may seem like a clever trick, but really it should be your very last resort in truly exceptional circumstances where there's just no other good way to accomplish what you want. You should resist the temptation to use it widely because it's an extremely inefficient way to execute code and also tends to obscure the meaning of your code. If what you want is a collection of related variables indexed by number, use an array. That's what they were invented for.
__________________
-- Greg |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
delay_to_wait_after_tuning variable | fract4l | SageTV Linux | 1 | 02-08-2009 01:51 PM |
Table with variable size cells | bialio | SageTV Studio | 13 | 01-21-2008 03:05 PM |
DisplayIndex as a global variable? | Crashless | SageTV Studio | 2 | 12-30-2007 11:01 AM |
Must be doing something stupid, can't pass a variable to a new menu. | stanger89 | SageTV Studio | 14 | 02-23-2007 05:24 PM |
Variable playback speeds... | grooves12 | SageTV Customizations | 0 | 03-04-2006 04:46 AM |