Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11719
| From | "Dave \"Crash\" Dummy" <invalid@invalid.invalid> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? |
| Date | 2017-07-22 07:58 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <okvedv$74f$1@dont-email.me> (permalink) |
| References | <okvc0l$d0p$1@gioia.aioe.org> |
R.Wieser wrote:
> I'm writing a script in which I want to execute some child scripts,
> and return a result. Like this:
>
> result = execute(oFS.OpenTextFile("childscript.vbs").ReadAll)
>
> Two things: I do not see any way to return such a result, nor do I
> see any way to, if needed, provide arguments.
>
> I'm aware that the executed script can just access and/or change some
> of its parents data (scope permitting ofcourse), but I was wondering
> if I could handle it more like an external function.
I don't know if there is a more elegant way to do it, but I pass
arguments and results with text files. The parent and child scripts can
read and/or write the data files. The only tricky part is making sure the
data file is finished and closed before the receiving script tries to
access it. Here is a simple example of a parent script passing variables
to a child script which processes the data then passes it back to the
parent, which displays the processed data in a message box.
'=================== parent.vbs =========================
Set fso=WScript.CreateObject("Scripting.FileSystemObject")
Set datafile=fso.CreateTextFile("data.txt")
datafile.writeLine "Var1=10"
datafile.writeLine "Var2=20"
datafile.writeLine "Var3=30"
datafile.close
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("childscript.vbs", 1, true)
Set datafile=fso.OpenTextFile("data.txt")
data=datafile.readAll
datafile.close
fso.deleteFile("data.txt")
msgbox data
'=================childscript.vbs================
Set fso=WScript.CreateObject("Scripting.FileSystemObject")
Set datafile=fso.OpenTextFile("data.txt")
data=datafile.readAll
datafile.close
Set datafile=fso.CreateTextFile("data.txt")
lines=split(data,vbCRLF)
datafile.writeLine split(lines(0),"=")(0) & "=" &
sqr(split(lines(0),"=")(1))
datafile.writeLine split(lines(1),"=")(0) & "=" &
sqr(split(lines(1),"=")(1))
datafile.writeLine split(lines(2),"=")(0) & "=" &
sqr(split(lines(2),"=")(1))
datafile.close
--
Crash
"Sometimes a cigar is just a cigar."
~ Sigmund Freud ~
Back to microsoft.public.scripting.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 13:14 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-22 13:41 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 14:16 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-07-22 07:58 -0400
Re: the "execute" command, arguments and returning a result. Possible? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 14:29 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? Ulrich Möller <knobbi38@arcor.de> - 2017-07-22 14:53 +0200
Re: the "execute" command, arguments and returning a result. Possible? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 16:28 +0200
Re: the "execute" command, arguments and returning a result. Possible? If so, how ? Ulrich Möller <knobbi38@arcor.de> - 2017-07-23 13:49 +0200
Re: the "execute" command, arguments and returning a result.Possible? If so, how ? "R.Wieser" <address@not.available> - 2017-07-24 08:29 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? JJ <jj4public@vfemail.net> - 2017-07-22 19:58 +0700
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 16:52 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Mayayana" <mayayana@invalid.nospam> - 2017-07-22 09:28 -0400
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-22 17:09 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Mayayana" <mayayana@invalid.nospam> - 2017-07-23 08:41 -0400
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-24 10:52 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Mayayana" <mayayana@invalid.nospam> - 2017-07-24 08:38 -0400
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-24 18:45 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-25 10:02 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-25 14:18 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-25 23:42 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-26 08:20 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-26 10:21 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-26 14:14 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-26 19:34 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-27 09:11 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-07-27 09:18 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-07-27 12:44 +0200
Re: the "execute" command, arguments and returning a result. Possible ? If so, how ? "R.Wieser" <address@not.available> - 2017-08-01 23:21 +0200
csiph-web