Page 1 of 1

C-ROADS INTERFACE

Posted: Sun Jul 08, 2012 4:50 am
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

Re: C-ROADS INTERFACE

Posted: Mon Jul 09, 2012 9:42 am
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.

Re: C-ROADS INTERFACE

Posted: Tue Jul 10, 2012 4:49 am
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

Re: C-ROADS INTERFACE

Posted: Sat Jul 14, 2012 10:13 pm
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

Re: C-ROADS INTERFACE

Posted: Mon Jul 16, 2012 2:50 pm
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.

Re: C-ROADS INTERFACE

Posted: Mon Jul 16, 2012 9:34 pm
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

Re: C-ROADS INTERFACE

Posted: Tue Jul 17, 2012 9:36 am
by Administrator
No you are not being pushy. We had a few issues with the 6.0 Vensim release that needed urgent attention.

Re: C-ROADS INTERFACE

Posted: Wed Jul 18, 2012 4:08 am
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

Re: C-ROADS INTERFACE

Posted: Wed Jul 18, 2012 1:58 pm
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.

Re: C-ROADS INTERFACE

Posted: Wed Jul 18, 2012 9:55 pm
by drees
Hi Tony

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

Thanks

David

Re: C-ROADS INTERFACE

Posted: Thu Jul 19, 2012 9:03 am
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 27256 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 27256 times
All should now work as you expect.

Tony.

Re: C-ROADS INTERFACE

Posted: Thu Jul 19, 2012 9:38 am
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

Re: C-ROADS INTERFACE

Posted: Thu Jul 19, 2012 10:08 am
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