Calling subroutines

For questions regarding programming in the EViews programming language.

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

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Calling subroutines

Postby javiersan » Fri Oct 15, 2010 1:19 am

Hello,

Is there a way of making something like the code below work?

Code: Select all

for %proc proc1 proc2 proc3 proc4 call myprocedure_{%proc} next subroutine myprocedure_proc1 ... endsub subroutine myprocedure_proc2 ... endsub etc.
Many thanks,

Javier

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Calling subroutines

Postby trubador » Fri Oct 15, 2010 3:07 am

There are plenty of ways to carry out such a task. Below you can find the two of them:

Code: Select all

for %proc proc1 proc2 proc3 proc4 %sub = "myprocedure_"+%proc call {%sub} ... next

Code: Select all

for !i=1 to 4 %sub = "myprocedure_proc"+@str(!i) call {%sub} ... next
You can also write down a more general code. String vectors might be very useful for that matter...

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Calling subroutines

Postby javiersan » Fri Oct 15, 2010 4:18 am

Thanks, I see where my problem was.

This works
%proc="myprocedure_proc1"
call {%proc}

but this doesn't seem to work
%proc="proc1"
call myprocedure_{%proc}

Regards,

Javier


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests