SIMULATE>SETVAL

Use this forum to post Vensim related questions.
Post Reply
rolando
Member
Posts: 22
Joined: Wed Dec 08, 2004 6:11 pm

SIMULATE>SETVAL

Post by rolando »

Hi,

I'm just trying to use the SETVAL function in Excel, but I can't find the way to set the value to a variable with subscripts.

I'm using the SETVAL like in this example:

For x = 1 To 40
ro = x + 3
num$ = Worksheets("Sheet1").Cells(ro, 40).Value
con$ = x
comstr$ = "SIMULATE>SETVAL|vd[l" + con$ + "] = " + num$
result = vensim_command(comstr$)
If result = 0 Then Exit Sub
Next

Name of the subscripts: l1,l2,l3,l4,l5...
Name of the variable: vd.

I read in the manual that you need to surround the command in double quotes " ", but I don't understand.

thank's
Administrator
Super Administrator
Posts: 4827
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Can you show us a copy of what the variable
comstr$ takes before you pass it to Vensim?

I seem to remember that some times, the "+" when used with strings inserts some extra spaces. That could be the cause of the problem.

Tony.
rolando
Member
Posts: 22
Joined: Wed Dec 08, 2004 6:11 pm

Post by rolando »

hi,

this is the value that it takes for the first 5:

SIMULATE>SETVAL|vd[l1] = 1
SIMULATE>SETVAL|vd[l2] = 2
SIMULATE>SETVAL|vd[l3] = 3
SIMULATE>SETVAL|vd[l4] = 4
SIMULATE>SETVAL|vd[l5] = 5

thank's
Administrator
Super Administrator
Posts: 4827
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

It looks like it should work fine. What is the error message you are getting?

Tony.
rolando
Member
Posts: 22
Joined: Wed Dec 08, 2004 6:11 pm

Post by rolando »

Hi,

I wasn't receiving any type of error....

But, now it's working...

The problem was after I set the initial values. I was trying to get the value of a constant, with the vensim_get_data, I just get another variable (level) and it work's fine.

your comments were very helpful
thank's Tony.
Post Reply