Hello world,

in a .vbs script, how can I use functions that are defined in another .vbs
file?
Is there an equivalent to #include in C?
Should be a rather simple question, but i haven't found anything about
this...

Jens

Re: Include Mechanism by ekkehard

ekkehard
Sat Apr 08 08:39:10 CDT 2006

Jens Lenge wrote:
> Hello world,
>
> in a .vbs script, how can I use functions that are defined in another
> .vbs file?
> Is there an equivalent to #include in C?
> Should be a rather simple question, but i haven't found anything about
> this...
>
> Jens
See Msg "?? Can One Scrip Call Another in a Different File ??"

Re: Include Mechanism by mr_unreliable

mr_unreliable
Sat Apr 08 10:11:18 CDT 2006

Jens, there are (at least) two include mechanisms.

1. Use the "wsf" file format, rather than "vbs".
The "wsf" format allows you to "include" any number of scripts.
Here is how to include another script:

<script language="VBScript" src="myDrive:\myFolder\myScript.vbs">
</script>

2. Use fso to read your "include" script into memory, and then
use "Execute" or "ExecuteGlobal" to run the script.

Here's another "bonus" method:

Wrap your "include" script into a "Windows Script Component".
You may then "register" the component and use it from any script.
Or, it is possible (if you read the documentation carefully, or
search this ng archive for postings) -- to load and use the
methods and properties of your wsc directly, _without_ registering
your wsc.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


Jens Lenge wrote:
> Hello world,
>
> in a .vbs script, how can I use functions that are defined in another
> .vbs file?
> Is there an equivalent to #include in C?
> Should be a rather simple question, but i haven't found anything about
> this...
>
> Jens

Re: Include Mechanism by Slim

Slim
Sat Apr 08 10:10:07 CDT 2006

have look at this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/c999e0fa-3986-41be-90a9-3f8ae3a38253.asp

"Jens Lenge" <Spampot@gmx.net> wrote in message
news:e1892o$oo3$02$1@news.t-online.com...
> Hello world,
>
> in a .vbs script, how can I use functions that are defined in another .vbs
> file?
> Is there an equivalent to #include in C?
> Should be a rather simple question, but i haven't found anything about
> this...
>
> Jens



Re: Include Mechanism by Jens

Jens
Sat Apr 08 16:59:00 CDT 2006

Thanks for your answers!
Now I have some helpful starting points!

Re: Include Mechanism by axtens

axtens
Sun Apr 09 20:02:14 CDT 2006

Also have a look at <http://codeaholic.blogspot.com>. There's a
synthetic include used in most of the VBScript projects along with a
link to the "Rube Goldberg Memorial Scripting Page" where the idea came
from originally.

Regards,
Bruce.


Re: Include Mechanism by Alex

Alex
Mon Apr 10 07:17:25 CDT 2006

"axtens" <bruce_axtens@yahoo.com.au> wrote in message
news:1144630934.563468.312400@v46g2000cwv.googlegroups.com...
> Also have a look at <http://codeaholic.blogspot.com>. There's a
> synthetic include used in most of the VBScript projects along with a
> link to the "Rube Goldberg Memorial Scripting Page" where the idea came
> from originally.

Bruce,
I hope you're still not waiting on that follow-up email I meant to send
several months ago. In any case, I think I stole that particular idea from
Torgeir Bakken who stole it from Michael Harris who may have stolen it from
someone else a bit farther back. That page has always been more like a
pawnshop than a factory. :)



Re: Include Mechanism by axtens

axtens
Mon Apr 10 09:48:07 CDT 2006

ROTFL!

Well, wherever you got it from, it's served me well. I will eventually
get around to using the .WSF mechanism but until then ...

And thanks too for the stuff on the RGMSP, because I've referred to it
often and even keep a printout in a display-folder.

Regards,
Bruce.


Re: Include Mechanism by noone

noone
Mon Apr 10 16:19:03 CDT 2006

Il giorno 9 Apr 2006 18:02:14 -0700, "axtens" <bruce_axtens@yahoo.com.au> ha scritto:

>Also have a look at <http://codeaholic.blogspot.com>. There's a
>synthetic include used in most of the VBScript projects along with a
>link to the "Rube Goldberg Memorial Scripting Page" where the idea came
>from originally.

"resistence is futile. you'll be included!"


Include "c:\documenti\Giovanni\libreria.vbs"


Function Include(vbslibrary)
' http://digilander.libero.it/Cenati
dim fso,f,s
set fso=createobject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(vbslibrary)
s=f.ReadAll
f.Close
ExecuteGlobal s
end function



--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (VbScript)
--