Creating default options for add-in

For tips, questions and general information about writing Add-ins, how to package them, and how to submit them to EViews for publication.

Moderators: EViews Gareth, EViews Moderator

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Creating default options for add-in

Postby Elderfield.A » Tue Apr 14, 2020 12:54 am

Hi,

I am wondering how to write an add-in that has some default options pre-populated, which can then be overridden with the procs command. For example, say I have an add-in called "silly_addin" that creates a copy of a variable, then multiplies it by 100. And I want to be able to provide the option to change the scalar 100 and the string name name of the copied variable, if provided. If not, I want them to be the defaults "silly_name" and 100.

I think the add-in would look something like this:

Code: Select all


%name = "silly_name"
!multiplier  = 100

%name = @getnextname(%name)
series {%name} =  _this.default*!multiplier



And I am hoping to do something like this

Code: Select all


variable.silly_name "new_silly_name" 200



Which should return a new variable called "new_silly_name" which is equal to variable*200. However, if I did this

Code: Select all


variable.silly_name



I'd get a new variable called "silly_name" which is equal to variable*100 (the defualts)


I hope this example is clear enough, I obviously don't want to do this exactly, but I want to be able to run an add-in via a proc command and have the ability to change default settings.

Thanks

Adam

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12637
Joined: Tue Sep 16, 2008 5:38 pm

Re: Creating default options for add-in

Postby EViews Gareth » Tue Apr 14, 2020 1:14 pm

Program Options or Program Arguments are what you want.
http://eviews.com/help/helpintro.html#p ... ns.html%23


If you can't get them to work, lmk.
Follow us on Twitter @IHSEViews

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: Creating default options for add-in

Postby Elderfield.A » Tue Apr 14, 2020 5:13 pm

That was just exactly what I was after, thanks Gareth. I am having a little trouble with the use of "_this" - I have read the post in this forum about it but I couldn't really answer my problem. What I want to do, if the option is specified is transform the selected variable

Code: Select all

%name1 = @getnextname("x")
series  {%name1} = _this.sheet
series  {%name1}= {%name1}/{%name1}(-4)*100-100



I get the error "SHEET is not a member or procedure of VARIABLE in "SERIES {%NAME1} = _THIS.SHEET". Note, I get the same error I use _this.display, _this.defualt (both of which bring up the spreadsheet view if I type them into the command bar). If I simply do _this, then I get an empty object (i.e. no data in the series.

I'm sure I am missing something obvious here...

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12637
Joined: Tue Sep 16, 2008 5:38 pm

Re: Creating default options for add-in

Postby EViews Gareth » Wed Apr 15, 2020 12:11 am

Elderfield.A wrote:

Code: Select all


series  {%name1} = _this.sheet






What are you intending with this line?
Follow us on Twitter @IHSEViews

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: Creating default options for add-in

Postby Elderfield.A » Thu Apr 16, 2020 4:26 pm

I was trying to access the series objects data so I could transform it. As I understand it, .sheet brings the spreadsheet view of the object?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12637
Joined: Tue Sep 16, 2008 5:38 pm

Re: Creating default options for add-in

Postby EViews Gareth » Thu Apr 16, 2020 4:29 pm

Correct, but I still don't see what you're trying to do.
Follow us on Twitter @IHSEViews

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: Creating default options for add-in

Postby Elderfield.A » Thu Apr 16, 2020 4:55 pm

Sorry for note being clear on this, I want to create a new series, based on the data contained in _this. My attempts of manipulating _this. directly were failing, but I more than likely was doing something wrong.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12637
Joined: Tue Sep 16, 2008 5:38 pm

Re: Creating default options for add-in

Postby EViews Gareth » Fri Apr 17, 2020 7:36 am

Code: Select all

series {%name} = _this
Follow us on Twitter @IHSEViews

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: Creating default options for add-in

Postby Elderfield.A » Tue Apr 21, 2020 11:06 pm

Yep - must of been one of those days for me. This works, thanks!


Return to “Add-in Writing area”

Who is online

Users browsing this forum: No registered users and 1 guest