vbscript - VBS Read Variable NAME and Data from file -


i creating script contain variables need set user. created ini file variables can defined user without having mess script itself. need vbs script able read file , create variable based on first part of line , set value of variable based on second part of line.

the ini file looks this

path=c:\users\whatever filename=whatever.txt filetypes=txt,doc,mp3,etc 

in batch file, easy, can do:

for /f "delims=" %%x in (config.ini) (set "") 

i love if there equally simple answer in vbs, here have (working)

filename = "config.ini" set fso = createobject("scripting.filesystemobject") set f = fso.opentextfile(filename) until f.atendofstream   linearray = split(f.readline , "=")     select case linearray(0)         case "path"             path = linearray(1)         case "filename"             fname = linearray(1)         case "filetypes"             filetypes = linearray(1)     end select loop  f.close 

this works, had rename variables myself, , script more difficult maintain , not efficient.

it nice if replace case statement more like

dim "linearray(0)"=linearray(1) 

and have vbs recognize linearray(0) should defined new variable using value of linearray(0) name of variable.

is there way in vbs?

i figured out. answer execute. simple line needed was:

execute(linearray(0) + " = " + "linearray(1)")


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -