Page 1 of 1

SIMULATE>SETVAL

Posted: Wed Jun 15, 2005 5:40 pm
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

Posted: Wed Jun 15, 2005 5:56 pm
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.

Posted: Wed Jun 15, 2005 6:03 pm
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

Posted: Wed Jun 15, 2005 7:20 pm
by Administrator
It looks like it should work fine. What is the error message you are getting?

Tony.

Posted: Wed Jun 15, 2005 10:11 pm
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.