Vensim Get Data with subscript

Use this forum to post Vensim related questions.
Post Reply
megboyar
Senior Member
Posts: 55
Joined: Mon Nov 16, 2009 7:22 am

Vensim Get Data with subscript

Post 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)
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Vensim Get Data with subscript

Post 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
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply