Re: Passing values between files
- From: "Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx>
- Date: Mon, 30 May 2005 20:19:55 -0600
"KAREN27" <KAREN27@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0F4C4F92-AADB-4B96-BB9A-62EB36F1AE8B@xxxxxxxxxxxxxxxx
> Hi all,
>
> What Al said is correct. I have a function in one wsf file that gets
> information fed to it via arguments within the same scriped file. This all
> works fine, although what I would like to do is to use this function the
same
> way, but to also get information fed to it from other wsf files that are
> external to the wsf file that contains the function.
>
> So basically all I need to do is pass values from one file to another.
You can't actually do that without making some structural changes to the
files containing the routines you want to call. I assume from what you say
that the function you want to be accessible from different .wsf files is
actually located in a "<script>" block in a .wsf file. If that is the case,
the simplest method would be for you to:
- copy the function (plus any other functions, subs, classes, const's, or
global variables it requires) to a .vbs file;
- delete the function code from the <script> block it is contained in in
the .wsf;
- add a new <script> block to the .wsf file to reference the new .vbs file
using "src=", i.e., add a line like the following immediately before the
<script> block you removed the function from:
<script language="VBScript" src="myfunction.vbs"/>
(be sure to include the trailing "/")
If the new .vbs file is not located in the same folder as the .wsf, you will
need to give a fully qualified path. The function itself is invoked from the
code in your .wsf in the usual manner just by referencing the function name
with appropriate parameters.
Once you get this working, you can then add the same script block to any
other .wsf's that need to use the function, but of course, you will need to
edit the script contained in those files so that they reference the function
by name.
One further tip that you might find helpful: try not to think of your code
as calling script files, or passing values to script files. The files
themselves do not actually do anything other than contain your script code
in a manner that allows the scripting host to read the code and compile it
into memory. And it is the compiled code in memory that is actually
executed.
That may seem like an abstract distinction; if it makes sense to you use
it - otherwise don't worry about it.
/Al
> Thanks again for your help
> Karen
>
>
> "Al Dunbar [MS-MVP]" wrote:
>
> >
> > "McKirahan" <News@xxxxxxxxxxxxx> wrote in message
> > news:PY6dnRyZ0bcjNwzfRVn-2g@xxxxxxxxxxxxxx
> > > "KAREN27" <KAREN27@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > news:12596C48-E767-47F6-A129-206F6FC88575@xxxxxxxxxxxxxxxx
> > > > Hi all,
> > > >
> > > > I've created a function that gets fed information from various
arguments
> > > > within the same scripted JScript file. The function then extracts
this
> > fed
> > > > information into an external text file.
> > > >
> > > > All of this works OK, although what I'm trying to achieve is to use
this
> > > > function in such a way that it receives information from external
> > scripted
> > > > files, not just from arguments within the same scripted file.
> > > >
> > > > Basically all I need to do is get information from other external
> > JScript
> > > > files, and feed them into this function.
> > > >
> > > > Thanks very much for your help
> > > > Karen
> > >
> > > Along the lines of an INI file?
> > >
> > > Look into the FileSystemObject to read files.
> >
> > What I think she might be asking is how can a script located in one file
> > call a function that is located in an another file, i.e. an "external
> > scripted file". If so, there are a number of ways this could be done,
the
> > best choice likely depending on the nature of the particular
application. If
> > she replies with more info, maybe we will be able to help.
> >
> > /Al
> >
> >
> >
.
- References:
- Passing values between files
- From: KAREN27
- Re: Passing values between files
- From: McKirahan
- Re: Passing values between files
- From: Al Dunbar [MS-MVP]
- Re: Passing values between files
- From: KAREN27
- Passing values between files
- Prev by Date: Passing values to an external function - Att Al Dunbar
- Next by Date: Re: Passing values to an external function - Att Al Dunbar
- Previous by thread: Re: Passing values between files
- Next by thread: Sort order of folders collection
- Index(es):
Relevant Pages
|
Loading