I found the following reference on the internet at AVID's web site and
since i had never heard of the Include statement before i wondered if
anyone else has and if this is now obsolete as the page was dated
2002. Can't believe that this feature would be removed in such a short
space of time 2002-2004/5.

Using this method would really help me with my code, already using a
similar process via Function calls however pulling from another file
seems more practical to me, though those of you who are more
conversant with VBS may be able to provide better direction on this.

Also looking at the 5.6 CHM there is no reference to the include
statement that i have found so far.

-----snip it

Including External Scripts (Windows Only)
You can include an external script file (.vbs or .js) in another
script file. This lets you reuse common routines without the need to
paste them into every file. Once you have included a script file as
shown below, the routines exist in the global namespace and you can
call them in the same way you would call any other routine in the
script.


These techniques work only on Windows platforms. This is because the
Scripting.FileSystemObject is not available on IRIX or Linux.



Including External Files Using VBScript
Here's an example of including external .vbs files using VBScript:


'-------------------------------------------------------
'-- Include procedure, works only on Windows
'-----------------------------------------------------------

Sub Include( cNameScript )
Set oFS = CreateObject("Scripting.Filesystemobject")
Set oFile = oFS.OpenTextFile( cNameScript )
ExecuteGlobal oFile.ReadAll()
oFile.Close
End Sub

'-- Samples
Include "C:\user\username\Softimage\Scripts\globals.vbs"
Include "C:\user\username\\Softimage\Scripts\utils.vbs"



jp

Re: Incude statement - is there such a thing? by McKirahan

McKirahan
Fri Jan 28 13:39:12 CST 2005

"jp" <paulm@kcbbs.gen.nz> wrote in message
news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
> I found the following reference on the internet at AVID's web site and
> since i had never heard of the Include statement before i wondered if
> anyone else has and if this is now obsolete as the page was dated
> 2002. Can't believe that this feature would be removed in such a short
> space of time 2002-2004/5.
>
> Using this method would really help me with my code, already using a
> similar process via Function calls however pulling from another file
> seems more practical to me, though those of you who are more
> conversant with VBS may be able to provide better direction on this.
>
> Also looking at the 5.6 CHM there is no reference to the include
> statement that i have found so far.
>
> -----snip it
>
> Including External Scripts (Windows Only)
> You can include an external script file (.vbs or .js) in another
> script file. This lets you reuse common routines without the need to
> paste them into every file. Once you have included a script file as
> shown below, the routines exist in the global namespace and you can
> call them in the same way you would call any other routine in the
> script.
>
>
> These techniques work only on Windows platforms. This is because the
> Scripting.FileSystemObject is not available on IRIX or Linux.
>
>
>
> Including External Files Using VBScript
> Here's an example of including external .vbs files using VBScript:
>
>
> '-------------------------------------------------------
> '-- Include procedure, works only on Windows
> '-----------------------------------------------------------
>
> Sub Include( cNameScript )
> Set oFS = CreateObject("Scripting.Filesystemobject")
> Set oFile = oFS.OpenTextFile( cNameScript )
> ExecuteGlobal oFile.ReadAll()
> oFile.Close
> End Sub
>
> '-- Samples
> Include "C:\user\username\Softimage\Scripts\globals.vbs"
> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
>
>
>
> jp

Where are you looking to use this?


If inside a Web page, try:

<script type="text/javascript" src="your_include_file.js"></script>

or if you want to do it in VBScript for IE only browsers:

<script type="text/vbscript" src="your_include_file.vbs"></script>


The extension doesn't matter; ".inc" is often used.


If it's for an ASP page, try:

<!--#include file="your_include_file.asp"-->


You could also look into WSF.



Re: Incude statement - is there such a thing? by Torgeir

Torgeir
Fri Jan 28 13:58:55 CST 2005

jp wrote:

> I found the following reference on the internet at AVID's web site and
> since i had never heard of the Include statement before i wondered if
> anyone else has and if this is now obsolete as the page was dated
> 2002. Can't believe that this feature would be removed in such a short
> space of time 2002-2004/5.
>
> Using this method would really help me with my code, already using a
> similar process via Function calls however pulling from another file
> seems more practical to me, though those of you who are more
> conversant with VBS may be able to provide better direction on this.
> (snip)
Hi

Several options are available to you.

For different methods and some examples of code libraries and their
pros and cons, you can take a look here (my favorite is WSC):

http://groups.google.co.uk/groups?selm=3E479EC6.6EFB4ADE%40hydro.com


Some interesting WSC links for future use maybe:

How to generate a WSC type library file automatically:
http://groups.google.co.uk/groups?selm=3EBD6A07.C56E6B71%40hydro.com

Optional methods to reference the WSC that is not registered from a script:
http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=uKQPMyT1BHA.2736%40tkmsftngp03



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Incude statement - is there such a thing? by jp

jp
Sun Jan 30 19:36:08 CST 2005


Currently the scripts i have are not ASP/Web orientated, just basic
scripts to deploy fixes and enchantments.

The idea would be great to have something like a Constants,vbs/txt
file that i could modify as required and not have to do the same to
all my scripts, so this type of feature feels good if i can understand
how to implement it without getting bogged down with rewriting my
scripts. Unless that's the only way.


jp

On Fri, 28 Jan 2005 13:40:45 -0600, "McKirahan" <News@McKirahan.com>
wrote:

>"jp" <paulm@kcbbs.gen.nz> wrote in message
>news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
>> I found the following reference on the internet at AVID's web site and
>> since i had never heard of the Include statement before i wondered if
>> anyone else has and if this is now obsolete as the page was dated
>> 2002. Can't believe that this feature would be removed in such a short
>> space of time 2002-2004/5.
>>
>> Using this method would really help me with my code, already using a
>> similar process via Function calls however pulling from another file
>> seems more practical to me, though those of you who are more
>> conversant with VBS may be able to provide better direction on this.
>>
>> Also looking at the 5.6 CHM there is no reference to the include
>> statement that i have found so far.
>>
>> -----snip it
>>
>> Including External Scripts (Windows Only)
>> You can include an external script file (.vbs or .js) in another
>> script file. This lets you reuse common routines without the need to
>> paste them into every file. Once you have included a script file as
>> shown below, the routines exist in the global namespace and you can
>> call them in the same way you would call any other routine in the
>> script.
>>
>>
>> These techniques work only on Windows platforms. This is because the
>> Scripting.FileSystemObject is not available on IRIX or Linux.
>>
>>
>>
>> Including External Files Using VBScript
>> Here's an example of including external .vbs files using VBScript:
>>
>>
>> '-------------------------------------------------------
>> '-- Include procedure, works only on Windows
>> '-----------------------------------------------------------
>>
>> Sub Include( cNameScript )
>> Set oFS = CreateObject("Scripting.Filesystemobject")
>> Set oFile = oFS.OpenTextFile( cNameScript )
>> ExecuteGlobal oFile.ReadAll()
>> oFile.Close
>> End Sub
>>
>> '-- Samples
>> Include "C:\user\username\Softimage\Scripts\globals.vbs"
>> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
>>
>>
>>
>> jp
>
>Where are you looking to use this?
>
>
>If inside a Web page, try:
>
><script type="text/javascript" src="your_include_file.js"></script>
>
>or if you want to do it in VBScript for IE only browsers:
>
><script type="text/vbscript" src="your_include_file.vbs"></script>
>
>
>The extension doesn't matter; ".inc" is often used.
>
>
>If it's for an ASP page, try:
>
><!--#include file="your_include_file.asp"-->
>
>
>You could also look into WSF.
>


Re: Incude statement - is there such a thing? by B-Mann

B-Mann
Sun Jan 30 19:51:56 CST 2005

I use the following in my .vbs files to include a common file that contains
global variables, constants, and useful functions:

ExecuteGlobal
CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Scripts\Common.inc").ReadAll

(The above should be on a single line)

B-Mann

"jp" <paulm@kcbbs.gen.nz> wrote in message
news:rj2rv0dh67de837jbaqfajl4g317o3op37@4ax.com...
>
> Currently the scripts i have are not ASP/Web orientated, just basic
> scripts to deploy fixes and enchantments.
>
> The idea would be great to have something like a Constants,vbs/txt
> file that i could modify as required and not have to do the same to
> all my scripts, so this type of feature feels good if i can understand
> how to implement it without getting bogged down with rewriting my
> scripts. Unless that's the only way.
>
>
> jp
>
> On Fri, 28 Jan 2005 13:40:45 -0600, "McKirahan" <News@McKirahan.com>
> wrote:
>
>>"jp" <paulm@kcbbs.gen.nz> wrote in message
>>news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
>>> I found the following reference on the internet at AVID's web site and
>>> since i had never heard of the Include statement before i wondered if
>>> anyone else has and if this is now obsolete as the page was dated
>>> 2002. Can't believe that this feature would be removed in such a short
>>> space of time 2002-2004/5.
>>>
>>> Using this method would really help me with my code, already using a
>>> similar process via Function calls however pulling from another file
>>> seems more practical to me, though those of you who are more
>>> conversant with VBS may be able to provide better direction on this.
>>>
>>> Also looking at the 5.6 CHM there is no reference to the include
>>> statement that i have found so far.
>>>
>>> -----snip it
>>>
>>> Including External Scripts (Windows Only)
>>> You can include an external script file (.vbs or .js) in another
>>> script file. This lets you reuse common routines without the need to
>>> paste them into every file. Once you have included a script file as
>>> shown below, the routines exist in the global namespace and you can
>>> call them in the same way you would call any other routine in the
>>> script.
>>>
>>>
>>> These techniques work only on Windows platforms. This is because the
>>> Scripting.FileSystemObject is not available on IRIX or Linux.
>>>
>>>
>>>
>>> Including External Files Using VBScript
>>> Here's an example of including external .vbs files using VBScript:
>>>
>>>
>>> '-------------------------------------------------------
>>> '-- Include procedure, works only on Windows
>>> '-----------------------------------------------------------
>>>
>>> Sub Include( cNameScript )
>>> Set oFS = CreateObject("Scripting.Filesystemobject")
>>> Set oFile = oFS.OpenTextFile( cNameScript )
>>> ExecuteGlobal oFile.ReadAll()
>>> oFile.Close
>>> End Sub
>>>
>>> '-- Samples
>>> Include "C:\user\username\Softimage\Scripts\globals.vbs"
>>> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
>>>
>>>
>>>
>>> jp
>>
>>Where are you looking to use this?
>>
>>
>>If inside a Web page, try:
>>
>><script type="text/javascript" src="your_include_file.js"></script>
>>
>>or if you want to do it in VBScript for IE only browsers:
>>
>><script type="text/vbscript" src="your_include_file.vbs"></script>
>>
>>
>>The extension doesn't matter; ".inc" is often used.
>>
>>
>>If it's for an ASP page, try:
>>
>><!--#include file="your_include_file.asp"-->
>>
>>
>>You could also look into WSF.
>>
>



Re: Incude statement - is there such a thing? by jp

jp
Tue Feb 01 00:17:23 CST 2005

Thanks a lot, works like a dream and now my codes much smaller and i
feel better managed.

Do you know the overhead on memory when using this, as i have created
two separate files and they work well together but i am unsure as to
if they are constantly loaded into memory or per script.

I have 15 scripts with the references in that you mention and wonder
if this is an over kill.

jp

On Sun, 30 Jan 2005 20:51:56 -0500, "B-Mann" <b__mann@hotmail.com>
wrote:

>I use the following in my .vbs files to include a common file that contains
>global variables, constants, and useful functions:
>
>ExecuteGlobal
>CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Scripts\Common.inc").ReadAll
>
>(The above should be on a single line)
>
>B-Mann
>
>"jp" <paulm@kcbbs.gen.nz> wrote in message
>news:rj2rv0dh67de837jbaqfajl4g317o3op37@4ax.com...
>>
>> Currently the scripts i have are not ASP/Web orientated, just basic
>> scripts to deploy fixes and enchantments.
>>
>> The idea would be great to have something like a Constants,vbs/txt
>> file that i could modify as required and not have to do the same to
>> all my scripts, so this type of feature feels good if i can understand
>> how to implement it without getting bogged down with rewriting my
>> scripts. Unless that's the only way.
>>
>>
>> jp
>>
>> On Fri, 28 Jan 2005 13:40:45 -0600, "McKirahan" <News@McKirahan.com>
>> wrote:
>>
>>>"jp" <paulm@kcbbs.gen.nz> wrote in message
>>>news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
>>>> I found the following reference on the internet at AVID's web site and
>>>> since i had never heard of the Include statement before i wondered if
>>>> anyone else has and if this is now obsolete as the page was dated
>>>> 2002. Can't believe that this feature would be removed in such a short
>>>> space of time 2002-2004/5.
>>>>
>>>> Using this method would really help me with my code, already using a
>>>> similar process via Function calls however pulling from another file
>>>> seems more practical to me, though those of you who are more
>>>> conversant with VBS may be able to provide better direction on this.
>>>>
>>>> Also looking at the 5.6 CHM there is no reference to the include
>>>> statement that i have found so far.
>>>>
>>>> -----snip it
>>>>
>>>> Including External Scripts (Windows Only)
>>>> You can include an external script file (.vbs or .js) in another
>>>> script file. This lets you reuse common routines without the need to
>>>> paste them into every file. Once you have included a script file as
>>>> shown below, the routines exist in the global namespace and you can
>>>> call them in the same way you would call any other routine in the
>>>> script.
>>>>
>>>>
>>>> These techniques work only on Windows platforms. This is because the
>>>> Scripting.FileSystemObject is not available on IRIX or Linux.
>>>>
>>>>
>>>>
>>>> Including External Files Using VBScript
>>>> Here's an example of including external .vbs files using VBScript:
>>>>
>>>>
>>>> '-------------------------------------------------------
>>>> '-- Include procedure, works only on Windows
>>>> '-----------------------------------------------------------
>>>>
>>>> Sub Include( cNameScript )
>>>> Set oFS = CreateObject("Scripting.Filesystemobject")
>>>> Set oFile = oFS.OpenTextFile( cNameScript )
>>>> ExecuteGlobal oFile.ReadAll()
>>>> oFile.Close
>>>> End Sub
>>>>
>>>> '-- Samples
>>>> Include "C:\user\username\Softimage\Scripts\globals.vbs"
>>>> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
>>>>
>>>>
>>>>
>>>> jp
>>>
>>>Where are you looking to use this?
>>>
>>>
>>>If inside a Web page, try:
>>>
>>><script type="text/javascript" src="your_include_file.js"></script>
>>>
>>>or if you want to do it in VBScript for IE only browsers:
>>>
>>><script type="text/vbscript" src="your_include_file.vbs"></script>
>>>
>>>
>>>The extension doesn't matter; ".inc" is often used.
>>>
>>>
>>>If it's for an ASP page, try:
>>>
>>><!--#include file="your_include_file.asp"-->
>>>
>>>
>>>You could also look into WSF.
>>>
>>
>


Re: Incude statement - is there such a thing? by Al

Al
Tue Feb 01 21:51:35 CST 2005


"jp" <paulm@kcbbs.gen.nz> wrote in message
news:3i7uv0ldam77k5utvi1ae3mr18g2k5lqaa@4ax.com...
> Thanks a lot, works like a dream and now my codes much smaller and i
> feel better managed.

Good, but have you noticed that you get poorer compile time messages when
doing it this way?

> Do you know the overhead on memory when using this, as i have created
> two separate files and they work well together but i am unsure as to
> if they are constantly loaded into memory or per script.

That is a good question that I know part of the answer to. If the "included"
script defines subs, functions, classes, global constants, or global
variables, those items remain compiled into existence in memory until the
main script completes. The only way I know to reduce the memory requirement
of, for example, a very large function called BIG would be to include a file
that defines a much smaller version. I do not know for a fact, though, how
effectively this releases the memory dedicated to the old version.

I suspect that the same would hold true for any and all code included this
way, even if it were straight, inline, script level code. If, for example,
you had 50 statements that you wanted to execute 1000 times in a loop. If
you have that include call in the loop, it might be that 999 new instances
of this code would co-exist in memory, each having been executed only once,
and not being capable of being re-used. If that were the case, you would be
much better off to embed the 50 lines of code directly in the loop.

> I have 15 scripts with the references in that you mention and wonder
> if this is an over kill.

I think it might be. Reminds me a bit of a time long ago when I used to
tweak the assembler code output from a Fortran compiler to make it a bit
tighter and faster. IIWY, I would construct my code in the most
straightforward manner so that I was not writing code to manage code, and
not try to solve performance issues until they actually happen.

Alternately, have you considered using WSH's .WSF format? This allows you to
statically include source files, and even mix WSH-enabled languages.

/Al

> jp
>
> On Sun, 30 Jan 2005 20:51:56 -0500, "B-Mann" <b__mann@hotmail.com>
> wrote:
>
> >I use the following in my .vbs files to include a common file that
contains
> >global variables, constants, and useful functions:
> >
> >ExecuteGlobal
>
>CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Scripts\Common.
inc").ReadAll
> >
> >(The above should be on a single line)
> >
> >B-Mann
> >
> >"jp" <paulm@kcbbs.gen.nz> wrote in message
> >news:rj2rv0dh67de837jbaqfajl4g317o3op37@4ax.com...
> >>
> >> Currently the scripts i have are not ASP/Web orientated, just basic
> >> scripts to deploy fixes and enchantments.
> >>
> >> The idea would be great to have something like a Constants,vbs/txt
> >> file that i could modify as required and not have to do the same to
> >> all my scripts, so this type of feature feels good if i can understand
> >> how to implement it without getting bogged down with rewriting my
> >> scripts. Unless that's the only way.
> >>
> >>
> >> jp
> >>
> >> On Fri, 28 Jan 2005 13:40:45 -0600, "McKirahan" <News@McKirahan.com>
> >> wrote:
> >>
> >>>"jp" <paulm@kcbbs.gen.nz> wrote in message
> >>>news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
> >>>> I found the following reference on the internet at AVID's web site
and
> >>>> since i had never heard of the Include statement before i wondered if
> >>>> anyone else has and if this is now obsolete as the page was dated
> >>>> 2002. Can't believe that this feature would be removed in such a
short
> >>>> space of time 2002-2004/5.
> >>>>
> >>>> Using this method would really help me with my code, already using a
> >>>> similar process via Function calls however pulling from another file
> >>>> seems more practical to me, though those of you who are more
> >>>> conversant with VBS may be able to provide better direction on this.
> >>>>
> >>>> Also looking at the 5.6 CHM there is no reference to the include
> >>>> statement that i have found so far.
> >>>>
> >>>> -----snip it
> >>>>
> >>>> Including External Scripts (Windows Only)
> >>>> You can include an external script file (.vbs or .js) in another
> >>>> script file. This lets you reuse common routines without the need to
> >>>> paste them into every file. Once you have included a script file as
> >>>> shown below, the routines exist in the global namespace and you can
> >>>> call them in the same way you would call any other routine in the
> >>>> script.
> >>>>
> >>>>
> >>>> These techniques work only on Windows platforms. This is because the
> >>>> Scripting.FileSystemObject is not available on IRIX or Linux.
> >>>>
> >>>>
> >>>>
> >>>> Including External Files Using VBScript
> >>>> Here's an example of including external .vbs files using VBScript:
> >>>>
> >>>>
> >>>> '-------------------------------------------------------
> >>>> '-- Include procedure, works only on Windows
> >>>> '-----------------------------------------------------------
> >>>>
> >>>> Sub Include( cNameScript )
> >>>> Set oFS = CreateObject("Scripting.Filesystemobject")
> >>>> Set oFile = oFS.OpenTextFile( cNameScript )
> >>>> ExecuteGlobal oFile.ReadAll()
> >>>> oFile.Close
> >>>> End Sub
> >>>>
> >>>> '-- Samples
> >>>> Include "C:\user\username\Softimage\Scripts\globals.vbs"
> >>>> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
> >>>>
> >>>>
> >>>>
> >>>> jp
> >>>
> >>>Where are you looking to use this?
> >>>
> >>>
> >>>If inside a Web page, try:
> >>>
> >>><script type="text/javascript" src="your_include_file.js"></script>
> >>>
> >>>or if you want to do it in VBScript for IE only browsers:
> >>>
> >>><script type="text/vbscript" src="your_include_file.vbs"></script>
> >>>
> >>>
> >>>The extension doesn't matter; ".inc" is often used.
> >>>
> >>>
> >>>If it's for an ASP page, try:
> >>>
> >>><!--#include file="your_include_file.asp"-->
> >>>
> >>>
> >>>You could also look into WSF.
> >>>
> >>
> >
>



Re: Incude statement - is there such a thing? by mayayana

mayayana
Wed Feb 02 08:00:56 CST 2005

I can't imagine any memory usage issues.
The only increase is the memory required for
the included file (assuming he has the sense
to include it at script startup and not inside
a Do/Loop). It's no different from using a
SCRIPT....SRC=.... tag in HTML.

I guess this is another case of personal preference,
but the idea of a text file COM object seems
rather hokey to me. And it that WSF references
other script files (as the Docs often suggest to be
a good idea) then pretty soon your scripts are
dependent upon a shaky spider web of hard-coded
paths that become increasingly difficult to keep
track of, especially if you want to share a script with
someone else.

For the OP, this page has an in-depth discussion
of the uses of WSF:
http://blogs.msdn.com/gstemp/archive/2004/02/24/79183.aspx
--
_____________________________

mayayXXana1a@mindYYspring.com
For return email remove XX and YY.
_____________________________
Al Dunbar [MS-MVP] <alan-no-drub-spam@hotmail.com> wrote in message
news:u38sAqNCFHA.3368@TK2MSFTNGP10.phx.gbl...
>
> "jp" <paulm@kcbbs.gen.nz> wrote in message
> news:3i7uv0ldam77k5utvi1ae3mr18g2k5lqaa@4ax.com...
> > Thanks a lot, works like a dream and now my codes much smaller and i
> > feel better managed.
>
> Good, but have you noticed that you get poorer compile time messages when
> doing it this way?
>
> > Do you know the overhead on memory when using this, as i have created
> > two separate files and they work well together but i am unsure as to
> > if they are constantly loaded into memory or per script.
>
> That is a good question that I know part of the answer to. If the
"included"
> script defines subs, functions, classes, global constants, or global
> variables, those items remain compiled into existence in memory until the
> main script completes. The only way I know to reduce the memory
requirement
> of, for example, a very large function called BIG would be to include a
file
> that defines a much smaller version. I do not know for a fact, though, how
> effectively this releases the memory dedicated to the old version.
>
> I suspect that the same would hold true for any and all code included this
> way, even if it were straight, inline, script level code. If, for example,
> you had 50 statements that you wanted to execute 1000 times in a loop. If
> you have that include call in the loop, it might be that 999 new instances
> of this code would co-exist in memory, each having been executed only
once,
> and not being capable of being re-used. If that were the case, you would
be
> much better off to embed the 50 lines of code directly in the loop.
>
> > I have 15 scripts with the references in that you mention and wonder
> > if this is an over kill.
>
> I think it might be. Reminds me a bit of a time long ago when I used to
> tweak the assembler code output from a Fortran compiler to make it a bit
> tighter and faster. IIWY, I would construct my code in the most
> straightforward manner so that I was not writing code to manage code, and
> not try to solve performance issues until they actually happen.
>
> Alternately, have you considered using WSH's .WSF format? This allows you
to
> statically include source files, and even mix WSH-enabled languages.
>
> /Al
>
> > jp
> >
> > On Sun, 30 Jan 2005 20:51:56 -0500, "B-Mann" <b__mann@hotmail.com>
> > wrote:
> >
> > >I use the following in my .vbs files to include a common file that
> contains
> > >global variables, constants, and useful functions:
> > >
> > >ExecuteGlobal
> >
>
>CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Scripts\Common.
> inc").ReadAll
> > >
> > >(The above should be on a single line)
> > >
> > >B-Mann
> > >
> > >"jp" <paulm@kcbbs.gen.nz> wrote in message
> > >news:rj2rv0dh67de837jbaqfajl4g317o3op37@4ax.com...
> > >>
> > >> Currently the scripts i have are not ASP/Web orientated, just basic
> > >> scripts to deploy fixes and enchantments.
> > >>
> > >> The idea would be great to have something like a Constants,vbs/txt
> > >> file that i could modify as required and not have to do the same to
> > >> all my scripts, so this type of feature feels good if i can
understand
> > >> how to implement it without getting bogged down with rewriting my
> > >> scripts. Unless that's the only way.
> > >>
> > >>
> > >> jp
> > >>
> > >> On Fri, 28 Jan 2005 13:40:45 -0600, "McKirahan" <News@McKirahan.com>
> > >> wrote:
> > >>
> > >>>"jp" <paulm@kcbbs.gen.nz> wrote in message
> > >>>news:fm3lv09l4dmb2q3d7330ps33ndsbjc9vpd@4ax.com...
> > >>>> I found the following reference on the internet at AVID's web site
> and
> > >>>> since i had never heard of the Include statement before i wondered
if
> > >>>> anyone else has and if this is now obsolete as the page was dated
> > >>>> 2002. Can't believe that this feature would be removed in such a
> short
> > >>>> space of time 2002-2004/5.
> > >>>>
> > >>>> Using this method would really help me with my code, already using
a
> > >>>> similar process via Function calls however pulling from another
file
> > >>>> seems more practical to me, though those of you who are more
> > >>>> conversant with VBS may be able to provide better direction on
this.
> > >>>>
> > >>>> Also looking at the 5.6 CHM there is no reference to the include
> > >>>> statement that i have found so far.
> > >>>>
> > >>>> -----snip it
> > >>>>
> > >>>> Including External Scripts (Windows Only)
> > >>>> You can include an external script file (.vbs or .js) in another
> > >>>> script file. This lets you reuse common routines without the need
to
> > >>>> paste them into every file. Once you have included a script file as
> > >>>> shown below, the routines exist in the global namespace and you can
> > >>>> call them in the same way you would call any other routine in the
> > >>>> script.
> > >>>>
> > >>>>
> > >>>> These techniques work only on Windows platforms. This is because
the
> > >>>> Scripting.FileSystemObject is not available on IRIX or Linux.
> > >>>>
> > >>>>
> > >>>>
> > >>>> Including External Files Using VBScript
> > >>>> Here's an example of including external .vbs files using VBScript:
> > >>>>
> > >>>>
> > >>>> '-------------------------------------------------------
> > >>>> '-- Include procedure, works only on Windows
> > >>>> '-----------------------------------------------------------
> > >>>>
> > >>>> Sub Include( cNameScript )
> > >>>> Set oFS = CreateObject("Scripting.Filesystemobject")
> > >>>> Set oFile = oFS.OpenTextFile( cNameScript )
> > >>>> ExecuteGlobal oFile.ReadAll()
> > >>>> oFile.Close
> > >>>> End Sub
> > >>>>
> > >>>> '-- Samples
> > >>>> Include "C:\user\username\Softimage\Scripts\globals.vbs"
> > >>>> Include "C:\user\username\\Softimage\Scripts\utils.vbs"
> > >>>>
> > >>>>
> > >>>>
> > >>>> jp
> > >>>
> > >>>Where are you looking to use this?
> > >>>
> > >>>
> > >>>If inside a Web page, try:
> > >>>
> > >>><script type="text/javascript" src="your_include_file.js"></script>
> > >>>
> > >>>or if you want to do it in VBScript for IE only browsers:
> > >>>
> > >>><script type="text/vbscript" src="your_include_file.vbs"></script>
> > >>>
> > >>>
> > >>>The extension doesn't matter; ".inc" is often used.
> > >>>
> > >>>
> > >>>If it's for an ASP page, try:
> > >>>
> > >>><!--#include file="your_include_file.asp"-->
> > >>>
> > >>>
> > >>>You could also look into WSF.
> > >>>
> > >>
> > >
> >
>
>



Re: Incude statement - is there such a thing? by Al

Al
Wed Feb 02 22:04:22 CST 2005


"mayayana" <mayaXXyana1a@mindYYspring.com> wrote in message
news:s25Md.5725$S3.4612@newsread2.news.atl.earthlink.net...
> I can't imagine any memory usage issues.
> The only increase is the memory required for
> the included file (assuming he has the sense
> to include it at script startup and not inside
> a Do/Loop). It's no different from using a
> SCRIPT....SRC=.... tag in HTML.
>
> I guess this is another case of personal preference,
> but the idea of a text file COM object seems
> rather hokey to me.

Sounds like you are thinking of wsc more than wsf...

> And it that WSF references
> other script files (as the Docs often suggest to be
> a good idea) then pretty soon your scripts are
> dependent upon a shaky spider web of hard-coded
> paths that become increasingly difficult to keep
> track of, especially if you want to share a script with
> someone else.

Depends. If you reference external .vbs files with calls to an INCLUDE
function, these generally are given explicit paths, unless you add code to
manage locating the scripts. Given this, then, you might find you need to
modify your code just in order to run it from a different folder.

The .wsf format allows you to specify relative file paths to the included
script files. If the .vbs files are in the same folder as the .wsf, or in
subfolders of that subfolder, the entire thing can be moved anywhere and run
without modification. If you want to specify a common single copy of library
routines used by a number of different .wsf files, these can be given with
absolute paths. Certainly, you cannot make this adaptive by specifying paths
based on environment variables (at least I think not), but I do not think it
is quite as inflexible as you suggest.

> For the OP, this page has an in-depth discussion
> of the uses of WSF:
> http://blogs.msdn.com/gstemp/archive/2004/02/24/79183.aspx

Interesting article, thanks. But notice that his is not a unanimous decision
of "the guys" ;-)

His first "hellow world" example was a little facetious. Surely if you are
NOT going to include external files or do any of the other things that .wsf
allows (predefined objects like FSO, mixing languages, etc.) then wrapping
what would work in a .vbs file into a .wsf file doesn't seem to add any
value.

Also, the scripting guys generally avoid details like that (along with
things like DIM'ing variables, checking for error conditions, type libraries
etc) because their purpose is to explain certain aspects of scripting, and
don't want those other things getting in the way of simplifying a concept.
I've posted over-simplified code here for the same reason, code that I would
not generally run as is in my own environment.


/Al