<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JScript: Вызов встроенных функций VBScript]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=2208&amp;type=atom" />
	<updated>2008-09-04T13:52:16Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=2208</id>
		<entry>
			<title type="html"><![CDATA[JScript: Вызов встроенных функций VBScript]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=13832#p13832" />
			<content type="html"><![CDATA[<p>Для вызова встроенных функций VBScript, которых нет в JScript, можно воспользоваться следующим <a href="http://forum.script-coding.com/viewtopic.php?id=1037">компонентом</a>, <strong>VbsFunction.wsc</strong>:<br /></p><div class="codebox"><pre><code>&lt;?xml version=&#039;1.0&#039; encoding=&#039;windows-1251&#039; standalone=&#039;yes&#039;?&gt;
&lt;component id=&#039;VbsFunction&#039;&gt;
&lt;registration progid=&#039;VbsFunction&#039;/&gt;
&lt;public&gt;&lt;method name=&#039;vbs&#039; dispid=&#039;0&#039;/&gt;&lt;/public&gt;

&lt;script language=&#039;VBScript&#039;&gt;&lt;![CDATA[
Sub VbsEval(expression): PutVbsEvalResult(Eval(expression)): End Sub
]]&gt;&lt;/script&gt;

&lt;script language=&#039;JScript&#039;&gt;&lt;![CDATA[
var VbsFuncArgs, VbsEvalResult;
function PutVbsEvalResult(X) {VbsEvalResult=X;}
function GetVbsFuncArgs(i) {return VbsFuncArgs[i];}

function vbs(FuncName) {
  return new Function(
    &#039;VbsFuncArgs=arguments;&#039;+
    &#039;var count=VbsFuncArgs.length, Args=new Array(count);&#039;+
    &#039;for (var i=count; --i&gt;=0;) Args[i]=&quot;GetVbsFuncArgs(&quot;+i+&quot;)&quot;;&#039;+
    &#039;VbsEval(&quot;&#039; +FuncName+ &#039;(&quot;+Args+&quot;)&quot;);&#039;+
    &#039;var retVal=VbsEvalResult;&#039;+
    &#039;VbsFuncArgs=null; VbsEvalResult=null;&#039;+
    &#039;return retVal;&#039;
  );
}
]]&gt;&lt;/script&gt;
&lt;/component&gt;</code></pre></div><p>Пример использования из JScript:<br /></p><div class="codebox"><pre><code>vbs=new ActiveXObject(&quot;VbsFunction&quot;);
var InputBox=vbs(&quot;InputBox&quot;);
var X=InputBox(&quot;Введите число&quot;, &quot;Вызов InputBox из JScript&quot;);
vbs(&quot;MsgBox&quot;)(&quot;Вы ввели: &quot;+X);</code></pre></div><p>Автор решения - <strong>wisgest</strong>.<br />Конечно, всегда можно воспользоваться и более &quot;традиционным&quot; способом - форматом <a href="http://forum.script-coding.com/viewtopic.php?id=1149">WSF</a>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-09-04T13:52:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=13832#p13832</id>
		</entry>
</feed>
