2017-04-10 101 views
0

我正在寻找一个解决方案,它有助于在代码中导入文本文件,我这样做是为了移除硬编码的值。相反,我想调用一个文本文件并读取映射的值。使代码独立于项目。任何想法如何做到这一点?在DXL脚本中导入文本文件?

OleAutoObj createWrapperObj(Object obj) { 
OleAutoArgs args = create 
OleAutoObj wrapper = null 
print oleMethod(d2e, "CreateObjectWrapper", args, wrapper) 

olePut(wrapper, "ModuleName", name(m)) 
olePut(wrapper, "aObjectType", unicodeString(obj."aObjectType")) 
olePut(wrapper, "TestDescription", unicodeString(obj."Object Short Text")) 
olePut(wrapper, "TestPictureName", unicodeString(obj."ID")) 
olePut(wrapper, "TestFocus", unicodeString(obj."Test_Focus")) 

return wrapper } 

谢谢

回答

0

创建要在自己的行读取每个参数的文件。 以下是如何读取文件的示例。

string filename="C:/parameters.txt" // can also use relative paths 
Stream input = read filename 
string param 
input >> param //this reads the first line into the string param 

//... continue to input into each variable 
//... and then when all done 

close input 

我想这就是你要求的。