Sending "merged" string-list to subroutine

For questions regarding programming in the EViews programming language.

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

dagfinnrime
Posts: 54
Joined: Sat Oct 11, 2008 9:37 am
Location: Oslo
Contact:

Sending "merged" string-list to subroutine

Postby dagfinnrime » Wed Mar 20, 2013 1:21 pm

Hi,

I have a subroutine that does "wonderful" things. It's argument is a list of variables. Example:

Code: Select all

subroutine test(string %varlist) for %var {%varlist} do stuff in loop next endsub call test("var1 var2 var3")
I works nicely (for me).

Now a problem. Say I want to loop through the list "var1A var2A var3A var1B var2B var3B". Without the subroutine I could do it (a bit clumpsy, but ...) the following way:

Code: Select all

for %ext A B for %list var1{%ext} var2{%ext} var3{%ext} do stuff next next
or

Code: Select all

call test("var1A var2A var3A var1B var2B var3B")
But with many variables and "extensions" this becomes cumbersome.

My problem: How can I send something like "var1{%ext} var2{%ext} var3{%ext}" to the subroutine? I would love to do the following:

Code: Select all

for %ext A B call test("var1{%ext} var2{%ext} var3{%ext}") next
This, and variants thereof, does not work. Neither does (lots of variants):

Code: Select all

for %ext A B %var = "l_q_id"+%hor "l_rsprd_id"+%hor " call test(%var) next
The problem, as i understand it, is in the string-def.

Appreicate help.

Dagfinn

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

Re: Sending "merged" string-list to subroutine

Postby EViews Gareth » Wed Mar 20, 2013 2:17 pm

Did you try using the @wunion function to make the full list?

dagfinnrime
Posts: 54
Joined: Sat Oct 11, 2008 9:37 am
Location: Oslo
Contact:

Re: Sending "merged" string-list to subroutine

Postby dagfinnrime » Wed Mar 20, 2013 3:04 pm

I don't see how @wunion can help me. I don't want more elements in the list (at each step in the loop), I want to amend the elements in the list.

Two lists:
"var1 var2 var3" and "A B", to create "VAR1A Var2A Var3A" at first step in the loop, and "VAR1B VAR2B VAR3B" at the second. ...

But, you made me look more closely at the manual, and I could use @wcross

Thanks,

Dagfinn

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

Re: Sending "merged" string-list to subroutine

Postby EViews Gareth » Wed Mar 20, 2013 3:25 pm

heh, I was thinking of @wcross :oops:

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Re: Sending "merged" string-list to subroutine

Postby tV56x » Mon Sep 08, 2014 2:13 pm

I am using Eviews 7.

I'm getting the following error message:

"Maximum line length exceeded .... "

I've attached a picture with the error message.

The current length of this string is more than 500.

Thanks for help.
Attachments
Max_length_exceeded.png
Max_length_exceeded.png (20.18 KiB) Viewed 4997 times

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

Re: Sending "merged" string-list to subroutine

Postby EViews Gareth » Mon Sep 08, 2014 2:56 pm

You've exceeded the maximum line length in EViews 7. It was increased in EViews 8. You'll have to shorten your line.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests