Call a subroutine after an "append" command

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

freedomplaza
Posts: 13
Joined: Tue May 31, 2016 7:48 am

Call a subroutine after an "append" command

Postby freedomplaza » Tue May 31, 2016 8:05 am

I need to call a subroutine right after a system "append" command. Here is a minimal example

Code: Select all

model1.append call mysub '====== subroutine mysub %temp="c(1)" endsub
The result that I end up getting when I open "model1" is that it contains a line that reads "call mysub" as opposed to "c(1)".

I know that the example looks quite silly, and I could directly enter the command line "model1.append c(1)". However, the content of mysub will be substantially longer than what reported in the minimal example above and I will need to re-use it multiple times in the program. Hence the need of calling it from separate subroutine.

Thanks,
Ric

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

Re: Call a subroutine after an "append" command

Postby EViews Gareth » Tue May 31, 2016 8:21 am

I'm not sure what you're trying to do here.

Why would you have a subroutine call inside a system?

Perhaps you can explain what you're hoping to achieve, so we can tell you how to achieve it.

freedomplaza
Posts: 13
Joined: Tue May 31, 2016 7:48 am

Re: Call a subroutine after an "append" command

Postby freedomplaza » Tue May 31, 2016 8:28 am

The command "model1.append..." is issued inside a program that is supposed to populate a system to be estimated via GMM. The system "model1" consists of many moments conditions of the form "object1*object2=0", "object1*object3=0",... where "object1", "object2",... are very long functions (that depend on the parameters to be estimated interacted with other series), which I would like to specify once and for all in my program (to minimize the chances of errors and to keep the program manageable). Any help would be greatly appreciated.

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

Re: Call a subroutine after an "append" command

Postby EViews Gareth » Tue May 31, 2016 8:45 am

So what's the subroutine for?

Does the subroutine generate, programmatically using a for loop or something, all the permutations of the moment conditions? Or does it generate each moment condition one at a time, so you're calling the subroutine many times?

Either way, it is probably best to pass the system into the subroutine as an argument and have the subroutine calculate the string and then append it.

Or you could just have the subroutine spit out the string you want, then append that string to the subroutine.

freedomplaza
Posts: 13
Joined: Tue May 31, 2016 7:48 am

Re: Call a subroutine after an "append" command

Postby freedomplaza » Tue May 31, 2016 2:39 pm

So, I have followed your suggestion (thanks for that) and defined strings in the subroutine (outside of my main program) that are then invoked in the main program and appended as moment conditions for the GMM (which helps keeping my main program tidy). The issue that I am facing now is the following. When the string generated in the subroutine is short (eg "C(2)*RF_US*C(2)*RF_UK=0") everything works fine. However, when the string is long Eviews crashes with the error message "Eviews 8 has stopped working". Any suggestion on how I could get around this problem?

freedomplaza
Posts: 13
Joined: Tue May 31, 2016 7:48 am

Re: Call a subroutine after an "append" command

Postby freedomplaza » Tue May 31, 2016 4:50 pm

So, I think that the issue that I am having is that my strings (defined as %stringname="...") are too long. I guess that the size limit for a string is 1000 characters: any way of increasing that or getting around this issue?

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

Re: Call a subroutine after an "append" command

Postby EViews Gareth » Wed Jun 01, 2016 1:06 am

Unfortunately not.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests