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.
> > >>>
> > >>
> > >
> >
>
>