Problems of executing Sable Script

Use this forum to post Sable related questions.

Moderator: Administrator

Post Reply
cphan
Junior Member
Posts: 16
Joined: Mon Jun 16, 2014 3:31 pm
Vensim version: DSS

Problems of executing Sable Script

Post by cphan »

I try to get subscripts from model by using the following scripts

Code: Select all

Sub getSubscriptElements()

dim count as integer
dim value as string

count = GetNumberOfSubscriptElements("type")
msgbox ( count, "number" , MB_OK )

value = GetSubscriptElement("type",0)
msgbox ( value, "first value" , MB_OK )

value = GetSubscriptElement("type",1)
msgbox ( value, "second value" , MB_OK )
End Sub 
When I run this script directly in Sable, I have count = 0 instead of 2. I have count = 1952922682, value = "getsubscriptelement("type",0) if I execute this script from the published file .spk.
Any ideas ?
Thanks
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems of executing Sable Script

Post by Administrator »

Can you send the SPK? I'm getting identical results from one I've created.

Regarding "count", what happens if you try
count = GetNumberOfSubscriptElements(type)

I've already put a fix in that will try removing the quotes for the next update of Sable.
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
cphan
Junior Member
Posts: 16
Joined: Mon Jun 16, 2014 3:31 pm
Vensim version: DSS

Re: Problems of executing Sable Script

Post by cphan »

By removing the quotes, it works now in Sable Developer. Thanks!
But I have always the problems with .spk file. I attach here my test project.
Attachments
test.zip
(281.55 KiB) Downloaded 924 times
cphan
Junior Member
Posts: 16
Joined: Mon Jun 16, 2014 3:31 pm
Vensim version: DSS

Re: Problems of executing Sable Script

Post by cphan »

Can I use the function GetNumberOfSubscriptElements with a string variable ? For example:

Code: Select all

dim test as string
test = "type"
count = GetNumberOfSubscriptElements(test)
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems of executing Sable Script

Post by Administrator »

cphan wrote:Can I use the function GetNumberOfSubscriptElements with a string variable ? For example:

Code: Select all

dim test as string
test = "type"
count = GetNumberOfSubscriptElements(test)
Yes, it should work fine. Are you having trouble?
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
cphan
Junior Member
Posts: 16
Joined: Mon Jun 16, 2014 3:31 pm
Vensim version: DSS

Re: Problems of executing Sable Script

Post by cphan »

No, it doesn't work. GetNumberOfSubscriptElements(test) returns the number of elements of the subscript named "test"
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems of executing Sable Script

Post by Administrator »

You are right. I'll have it fixed in the next version.
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