RE: Calling functions in another .VBS
From: Tom Lavedas (tlavedas_at_hotmail.remove.com)
Date: 08/27/04
- Next message: Ruchi Dayal: "Re: Calling functions in another .VBS"
- Previous message: Ruchi Dayal: "Calling functions in another .VBS"
- In reply to: Ruchi Dayal: "Calling functions in another .VBS"
- Next in thread: Ruchi Dayal: "Re: Calling functions in another .VBS"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Aug 2004 07:43:04 -0700
Assuming your project scripts are VBS files and that your 'library file' only
contains functions and subroutines, they can be included by reading them into
a string in the calling script and then passing the string to either an
Execute or an ExecuteGlobal statement, something like this ...
if Include("C:\path\LibIncludeScript.vbs") = 0 Then
wsh.echo IncludeFunction("InputArgument")
else
wsh.echo "Error"
End if
Function Include(sFileSpec)
on Error Resume Next
With CreateObject("Scripting.FileSystemObject")
ExecuteGlobal .OpenTextFile(sFileSpec, 1).ReadAll
Include = Err.Number
End With
End Function
Be warned that the 'included' functions must be very robust (well tested and
with extensive error handling) as errors occurring within them are very hard
to diagnose when used this way.
Tom Lavedas
===========
"Ruchi Dayal" wrote:
> Hello:
>
> I have seen several messages when an include function helps in
> executing another .vbs.
>
> However, what I would like to do, is this:
>
> Make one "library" file which includes all common functions needed for
> a project. Then, from different .vbs scripts in the project, I should
> be able to call any function from this "library" file.
>
> Is this possible in .vbs ?
>
> Thanks,
>
- Next message: Ruchi Dayal: "Re: Calling functions in another .VBS"
- Previous message: Ruchi Dayal: "Calling functions in another .VBS"
- In reply to: Ruchi Dayal: "Calling functions in another .VBS"
- Next in thread: Ruchi Dayal: "Re: Calling functions in another .VBS"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|