including subs with variable names

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

lgehrig
Posts: 4
Joined: Fri Mar 17, 2017 8:10 am

including subs with variable names

Postby lgehrig » Fri Jul 28, 2017 1:37 am

Hello programmers

As I start to move subroutines out of my original program, I encountered this problem with variable subroutine names:

(The current directory is correctly set)

so this works:

Code: Select all

include MYSUB_US


but this doesnt:

Code: Select all

%Country ="US"
%MYSUB ="MYSUB_"+%Country

include {%MYSUB}


I get: K:\...\Code\{%MYSUB}.prg not found on disk.

Also building the filepath instead did not work. It appears file paths cannot contain replacement strings.

Does anyone know the answer?

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

Re: including subs with variable names

Postby EViews Gareth » Fri Jul 28, 2017 8:07 am

It is just as you say - you cannot dynamically include.
Follow us on Twitter @IHSEViews

lgehrig
Posts: 4
Joined: Fri Mar 17, 2017 8:10 am

Re: including subs with variable names

Postby lgehrig » Mon Jul 31, 2017 5:28 am

Thanks for the quick answer, Gareth!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 5 guests