Page 1 of 1

Vensim Get Data with subscript

Posted: Fri Aug 31, 2012 11:25 am
by megboyar
Hi,

When I use Vensim_Get_Data, I find that I must put the subscript element in the variable name, I can't put the actual name of the subscript range and get all the output. Any advice on how to simplify this process and just use the subscript name to get data on all the elements?

Many thanks,
Sarah

What I want to do:
tpoints = vensim_get_data("test.vdf", "Industry Volumes[Channel]", "time", qval(1), tval(1), 100)

What I must do:
tpoints = vensim_get_data("test.vdf", "Industry Volumes[supermarket]", "time", qval(1), tval(1), 100)
tpoints = vensim_get_data("test.vdf", "Industry Volumes[conveniencestore]", "time", qval(1), tval(1), 100)
tpoints = vensim_get_data("test.vdf", "Industry Volumes[gasstation]", "time", qval(1), tval(1), 100)

Re: Vensim Get Data with subscript

Posted: Fri Aug 31, 2012 12:28 pm
by Administrator
You can't get the data all at once.

But you can retrieve the list of subscript elements, and then concatenate that onto the parameter name and loop that way.

Eg,

Code: Select all

nCharsRequired = vensim_get_varattrib("Channel",8,0,0) ;
strBuffer = Space(nCharsRequired)

nCharsRequired = vensim_get_varattrib("Channel",8,strBuffer ,nCharsRequired ) ;

Do
   strSubscriptElement = space(50)
   nLen = vensim_get_substring(strBuffer,y,strSubscriptElement,50) ;
   If (nLen = 0) Then Exit Do

   tpoints = vensim_get_data("test.vdf", "Industry Volumes[" & strSubscriptElement  & "]", "time", qval(1), tval(1), 100)
   y = y + length
   x = x + 1
Loop