Page 1 of 1

Sending "merged" string-list to subroutine

Posted: Wed Mar 20, 2013 1:21 pm
by dagfinnrime
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

Re: Sending "merged" string-list to subroutine

Posted: Wed Mar 20, 2013 2:17 pm
by EViews Gareth
Did you try using the @wunion function to make the full list?

Re: Sending "merged" string-list to subroutine

Posted: Wed Mar 20, 2013 3:04 pm
by dagfinnrime
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

Re: Sending "merged" string-list to subroutine

Posted: Wed Mar 20, 2013 3:25 pm
by EViews Gareth
heh, I was thinking of @wcross :oops:

Re: Sending "merged" string-list to subroutine

Posted: Mon Sep 08, 2014 2:13 pm
by tV56x
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.

Re: Sending "merged" string-list to subroutine

Posted: Mon Sep 08, 2014 2:56 pm
by EViews Gareth
You've exceeded the maximum line length in EViews 7. It was increased in EViews 8. You'll have to shorten your line.