C-ROADS INTERFACE

Use this forum to post Sable related questions.

Moderator: Administrator

Post Reply
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

C-ROADS INTERFACE

Post by drees »

HI TONY

I've been using C-ROADS here in NZ to try and raise interest in using the model to help support conversations about climate change here in NZ. I've also used it to explore how you build interfaces and learning a lot. Amazing what you can find out by interrogating someone else's work - I hope you don't mind. One thing I can't work out however is how you've used the combo boxes in the control panel to call up the different graphs. I've worked out how you've used miniscreens and, looking at your scratchpad, it seems that there is a link to a variable in the vensim model called SABLE INPUT GRAPH SELECTED. However, I can't work out the role that is playing. Would you be willing to let me into your secret and explain how you are managing to call up all those graphs on the control panel using the top boxes.

I hope you don't mind me pulling your interface apart to explore these ideas but I find it a great way to learn new tricks.

Regards

David
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: C-ROADS INTERFACE

Post by Administrator »

It's fairly straightforward. I can produce a demo if you want, or alternatively, add some code to one of your projects to demonstrate it.

Let me know which is preferable.

Tony.
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
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

If you could produce a demo that would be great. I think that way I will learn a bit more, rather than simply getting you to add code to a model of mine. However, if it is easier I'm happy to send a suitable model to you.

Thanks for your support

David
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

Sorry to be pushy as I have no doubt you're very busy, but I am hoping to show the new model to the client within the next week want to finalize the interface soon. If you were able to post the demo that would be really helpful. I'm also happy to send you the model if inserting the code is easier for you.

Thanks again for all you support in helping me unravel the capabilities of Sable.

David
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: C-ROADS INTERFACE

Post by Administrator »

Sorry for the delay, I just needed to find a bit of time to put it together.

The attached project has a main screen. When it loads, one of the screen activation commands calls the script function OnScreenOpen_Main which populates the combo box containing the graph names.

There is also a static frame on this page. This is configured to show a mini screen.

Now when the user clicks the combo box, it calls the script function OnGraphSelect. This in turn reads the value that the user selected, and changes the contents of the frame to the relevant mini screen.

Hope this all makes sense.

Tony.
Attachments
Demo.zip
(30.1 KiB) Downloaded 2196 times
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
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

Thank you very much for this and I apologise if I was a bit pushy. I'm going to work through it and if I have any questions I'll get in touch.

Thanks again for being so supportive.

David
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: C-ROADS INTERFACE

Post by Administrator »

No you are not being pushy. We had a few issues with the 6.0 Vensim release that needed urgent attention.
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
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

Getting there. I've managed to get a drop box calling up the different graphs I need by using the script in the demo you sent as the template. I then tried to get a second combo box to call up a different set of graphs but with no luck. I tried this two ways:

Firstly, I simply did a copy and paste of the two sub-routines replacing the relevant data ID number, combo box names, mini screen names etc.
Secondly, I tried inserting the new information INSIDE each sub-routine by creating ID1 and ID2 i.e.

nComboBoxID1 = 4385
nComboBoxID2 = 4479

In populating the combo boxes I had:

call SetControlProperty(nComboBoxID1,"ResetContent")
call SetControlProperty(nComboBoxID1,"AddString","Rate Requirements",1) etc...

call SetControlProperty(nComboBoxID2,"ResetContent")
call SetControlProperty(nComboBoxID2,"AddString","Rate Requirements Current Year",1)

I then used the same logic for the GraphSelect.

Neither strategy worked however so if you could give me some directions I would, as always, be very grateful

Thanks

David
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: C-ROADS INTERFACE

Post by Administrator »

Can you post the screen and script file and I'll take a look?

It's most likely just a syntax error on the script.
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
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

I've attached both versions of the script file I attempted and the relevant screen.

Thanks

David
Attachments
SableScripts.zip
(3.77 KiB) Downloaded 2213 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: C-ROADS INTERFACE

Post by Administrator »

Are you using the default text editor in the Mac? If yes, don't, use something like TextWrangler (the one that comes with the Mac is useless).

When I opened the script file, I saw the following.
TextEditProblem.jpg
TextEditProblem.jpg (20.54 KiB) Viewed 26931 times
The Mac editor has not put in the correct line breaks after "exit sub" which means the function is not read properly. It should be

Code: Select all

if ( nGraphSelected = 3 )
	call ChangeFrame(nFrameID,"Mini","Capital Projects.vnn")
	exit sub
endif
if ( nGraphSelected = 4 )
	call ChangeFrame(nFrameID,"Mini","External Debt.vnn")
	exit sub
endif
TextWrangler is the best free text editor I've found on the Mac.

Second problem is that you have two functions called "OnGraphSelect". Sable will always call the first one. So rename the 2nd one to be OnGraphSelect_2 (or something more meaningful)

You also need to configure the combo box to actually call the script. View the properties for the 2nd combo box, click the "Script" button and select OnGraphSelect_2.
Button.jpg
Button.jpg (36 KiB) Viewed 26931 times
All should now work as you expect.

Tony.
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
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Thanks Tony

Yes I was using the default txt editor - I'll get the one you recommended and then have a go a re-doing it.

I'll let you know if I have any problems.

David
drees
Senior Member
Posts: 73
Joined: Fri Jun 25, 2010 4:02 am

Re: C-ROADS INTERFACE

Post by drees »

Hi Tony

Just to let you know that I downloaded TestWrangler, made the few changes you described and all is working fine. I've also learnt a lot in the process.

Thank you so much for persevering I really appreciate your help - writing scripts is not my forte, but I am learning.

I'll try not to pester you again for awhile :-)

David
Post Reply