Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript - how to load one script as a library into another

Status
Not open for further replies.

johnlopez2000

Programmer
Aug 2, 2002
90
US
Colleagues,

this may be a dumb questions, but I am a relative newbie to VBScript.

In TCL/TK I can load a "library" script into another script via source or other commands. How can I do the same with VBScript, where one script may only contain function calls that I want to commonize to a whole host of other scripts?

Can you do modules or class libraries like in regular VB?

Can I create a DLL and then load it and call it's functions?

I would prefer to just load one script from another, but I'd like to know how to do all 3 approaches.

THANKS!


John Lopez
Enterprise PDM Architect
john.l.lopez@goodrich.com
 
There are a couple of options from the simple to the complex. The easiest is to simply read the entire include file into a variable and then use the ExecuteGlobal function to execute the included code. Voila...your functions are now available for use. The more complex yet elegant way is to create a .WSC file with the functions that you want to make common built into a class as methods. You can then register the class as a COM object and instantiate it just like any other COM object in your scripts.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Guys - thanks very much. Will try both methods!

Appreciate your help.

John


John Lopez
Enterprise PDM Architect
john.l.lopez@goodrich.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top