Include a functional library or any other VBscript code available in your current script

Share this post
FaceBook  Twitter  Mixx.mn     

To Include a functional library or any other VBscript code available in your current script, use following code:
Steps:
1) Create a filesystem object

2) Open functional library as a text file

3) Read all file data

4) use executeglobal to make available other vbscript code in your current script.

5) discard all variable         
         
 Code:       
'function to include the common file'
sub includeFile (fSpec)
    dim fileSys, file, fileData
'1) Create a filesystem object'   
    set fileSys = createObject ("Scripting.FileSystemObject")
   
'2) Open functional library as a text file'   
    set file = fileSys.openTextFile (fSpec)
   
'3) Read all file data '   
    fileData = file.readAll ()
    file.close
   
'4) use executeglobal to make available other vbscript code in your current script.   
    executeGlobal fileData
   
'5) discard all variable     
    set file = nothing
    set fileSys = nothing
end sub