Using the dict name coming from a string variable

Discussions about editing and cleaning data
Post Reply
AriSilva
Posts: 633
Joined: July 22nd, 2016, 3:55 pm

Using the dict name coming from a string variable

Post by AriSilva »

Hi folks,
Is there a way to write something like:
string dictName = "SD_PROF_10_ENTREVISTA_DICT";
setfile(dictName, "file.csdb");

I need to set the dictionary in a function depending on a parameter.
Best
Ari
Best
Ari
Gregory Martin
Posts: 1976
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Using the dict name coming from a string variable

Post by Gregory Martin »

There are a lot of times it would be nice to use a string variable to specify a dynamic dictionary / variable / etc., but unfortunately that's only supported in a few places. Your best bet would be to create a dummy function like:
function SetDictionaryFile(string dictionaryName, string filePath)
    when dictionaryName;
        "DICT1" -> setfile(DICT1, filePath);
        "DICT2" -> setfile(DICT2, filePath);
        "DICT3" -> setfile(DICT3, filePath);
    endwhen;
end;
Post Reply