DB Fetch names and replacement var conflicts

For questions regarding programming in the EViews programming language.

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

madm
Posts: 12
Joined: Mon Oct 23, 2017 1:13 pm

DB Fetch names and replacement var conflicts

Postby madm » Thu Nov 09, 2023 5:40 pm

We have some general purpose routines that fetch a user-specified list of variables from a database. Unfortunately some of the variables in the database can have the % character in them, which leads to some undesirable conflicts with program variables:

Code: Select all

%A = "some unrelated variable"
%VAR_TO_FETCH = "IR%AC*"
fetch {%VAR_TO_FETCH} ' Attempts to fetch "IRsome unrelated variableC" -- if I don't do the replacement then I get an error because of the * wildcard.


The only viable workaround I have found for this so is replace the "%" with "?"

Code: Select all

%A = "some unrelated variable"
%VAR_TO_FETCH = "IR%AC*"
%VAR_TO_FETCH = @replace(%VAR_TO_FETCH,"%","?")
fetch {%VAR_TO_FETCH} ' Attempts to fetch "IRsome unrelated variableC"


I was a little surprised the recursive replacements aren't a bit more intentional by requiring the curly braces in the string like:

Code: Select all

%A = "[INTENDED_SUBSTITUTION]"
%VAR_TO_FETCH2 = "IR{%A}C*"


Just noting in case anyone runs into this.

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 18 guests