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.