Page 1 of 1

Call a subroutine after an "append" command

Posted: Tue May 31, 2016 8:05 am
by freedomplaza
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

Re: Call a subroutine after an "append" command

Posted: Tue May 31, 2016 8:21 am
by EViews Gareth
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.

Re: Call a subroutine after an "append" command

Posted: Tue May 31, 2016 8:28 am
by freedomplaza
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.

Re: Call a subroutine after an "append" command

Posted: Tue May 31, 2016 8:45 am
by EViews Gareth
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.

Re: Call a subroutine after an "append" command

Posted: Tue May 31, 2016 2:39 pm
by freedomplaza
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?

Re: Call a subroutine after an "append" command

Posted: Tue May 31, 2016 4:50 pm
by freedomplaza
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?

Re: Call a subroutine after an "append" command

Posted: Wed Jun 01, 2016 1:06 am
by EViews Gareth
Unfortunately not.