Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling function in other VBS file and getting return value

309 views
Skip to first unread message

Eran

unread,
Sep 23, 2004, 1:04:42 PM9/23/04
to
Hi,

I want to know if there's a way to call a function which sits in other VBS
file. This function suppose to return value.
I want the caller sub/method/function to get that value. the caller sub is a
VBS as well.
using executeglobal does call the function but it doesn't get the ret va.

Any one?

10x, Eran.


Tom Lavedas

unread,
Sep 23, 2004, 2:05:04 PM9/23/04
to
What the ExecuteGlobal is supposed to do is 'include' the function into the
current script's 'namespace'. That makes it as if the function were loaded
as part of the current script. That is, you can now access its results in
the same way as any other function. For example, if sIncludeText is a string
variable containing the text of the function, Testit() , then ...

ExecuteGlobal sIncludeText
Result = TestIt(arguments)

will return the result you seek. The function can be called as many times
as you want with different argument, just as if it were part of the current
script's own text file. The main difference is that it is not easy to
troubleshoot any problems that might arise within the function. That's why
the generally prefered approach is to use the XML like WSF script approach
with a '<script src=filename.ext language=vbs>' tag to include the function
in your current job. See the 'XML Elements' entry in the WSH documentation
for more information on this approach.

Tom Lavedas
===========

Eran

unread,
Sep 23, 2004, 2:56:49 PM9/23/04
to
Hi, Tom.

10x for your help.
so basically, I should do the following:

Dim ofsFile,Ofs,Result
Set ofsFile = CreateObject("Scripting.FileSystemObject")
Set Ofs = ofsFile.OpenTextFile("c:\1.vbs")
Ofs.ReadAll
Ofs.Close

ExecuteGlobal Ofs
Result = RetVal() 'RetVal is a function in 1.vbs


"Tom Lavedas" <tlav...@hotmail.remove.com> wrote in message
news:26F7120A-C7EF-46C6...@microsoft.com...

Tom Lavedas

unread,
Sep 23, 2004, 5:27:08 PM9/23/04
to
Yup

Tom Lavedas
============

0 new messages