View Single Post
Old 21st October 2014, 04:34   #31  |  Link
wiseant
Registered User
 
Join Date: May 2007
Posts: 146
calling a variable using string + incremented value

Hi
Hope this is the right place to post this question

Hi

let's say I have a number of subtitles
c0="Hello World"
c1="Hello and GoodBye"
c2="Love is all you need"
c3="avisynth rocks"
c4="Gscript is awesome"


and I want to call these subtitles (variables) in a loop, where the value of k represents a different clip or image being processed in the loop and I want to add each subtitle

I can use this syntax to use subtitle c0

k=k.subtitle(c0, 8,460)

but how do I use this if I want to use the values of c0, c1, etc

I have been trying something like this

caption= "c" + string(i)
k=k.subtitle(caption,8,460)

this give me text strings "c0", "c1", "c2", . . .
but I want to get the "value" of c0, c1, c2, etc

I tried using

caption= eval("c" + string(i))

but I get "Script Error - invalid arguments to function "Subtitle""


TIA
wiseant is offline   Reply With Quote