Example of a JScript 9 E+ u" F7 u/ w( p% a" Q1 }
var vbOKCancel = 1;
5 E7 s3 H3 b# |& svar vbCancel = 2;
4 n: C* n P( ?, A% hvar vbInformation = 64; , w" s" k1 Z0 k p+ {9 A
var Finished=false; ! |& J) F. x4 G6 d
& x% ? B! @# pvar WSHShell = new ActiveXObject("WScript.Shell");
, f( r. K" h4 O, F( c- z9 J 8 g. P' C2 x. \3 \; I+ E% l
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
6 y5 ]* w! P% C5 t+ l% E
7 B2 i& {5 o# P' esimple.SetLicenseType("Runtime"); : b( l* k. v) \4 e% n8 w
# Y/ g2 w' a! e: Q6 H
try
n4 B3 d" h% m! r' @{ / J; _6 |2 h. @& j4 F, ~
// Enter the path to a model file! % t1 z# T3 ]9 q$ Q& q* p4 D
simple.LoadModel("C:\\Models\\Test.spp");
# |: q) w* v. a}
6 o! M l" B# f) y3 q3 Q* }catch (e) % A# ?# G& ~! d! t2 w# N7 I
{ & j6 S+ n+ i7 A
WScript.Echo("Could not load Model!");
% g$ W" N5 }& J. B n5 z WScript.Quit(); : |% [9 {* @2 `
}
: e ~* j2 a \3 X
+ u4 W D% @1 H6 ]6 X5 Utry
3 K+ l! z, i% y& K{
% i6 u6 J. Z7 F simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # z$ f- F0 z# Y$ J- d3 f0 c
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 8 e! s" W7 n5 l% U; e( f! r1 S4 ?
if (r == vbCancel) 5 P4 D2 j8 K( d$ \9 ~5 l% T# K
{ & [4 a2 D+ ~4 N2 I6 h
simple.CloseModel();
% O! T) l' |# p WScript.Quit(); " @# Y: w7 M* O6 k, X3 F8 V% |$ d
} 3 V7 _8 A. T) S
}
* E7 v& t- {" J H- K) K2 e
3 t* M" m8 n! I% Rsimple.StartSimulation(".Models.Frame.EventController");
4 a$ A; U: I) ? R# G8 [$ D# c3 Q
if (simple.IsSimulationRunning())
$ g; z7 i: Y' e" {! w _ WScript.Echo("Simulation is running!");
2 T" f- U. r/ ^+ w3 u( _0 Y6 ], A . J# L) s. u4 Q, w, x7 C: ^
// Wait until simulation is finished 9 Z. Y/ a! c$ _* ?! |- z
while (!Finished) WScript.Sleep(2000);
; q! | p+ W g9 Q% I. z" z * M1 ?' k9 i+ `- T
simple.CloseModel();
0 X* U8 w L7 T$ _1 e9 k1 z+ Csimple.Quit(); ) |* V1 x' i; a0 |3 R5 n
WScript.Quit(); / f6 m7 k; ~. y3 l
5 K, m8 @- l; \9 ?$ W& ` ( y$ N* w( b7 S: p& L6 m
function RemoteControl_SimulationFinished()
2 ?9 U0 [7 I4 ~* F! O, s{ 1 ]1 p1 {, N4 L% v( F- Q5 P
WScript.Echo("Simulation Finished!"); |