Example of a JScript 4 J+ x3 k% T# t7 {4 W0 ]4 h
var vbOKCancel = 1;
7 y U Q& `5 c. A1 y; }var vbCancel = 2; ( S' y6 z2 @2 `! P
var vbInformation = 64;
" r! T$ s. T+ N* Uvar Finished=false; , a, j6 w# W0 F( f
8 c: W7 x. p* J6 s5 H8 x
var WSHShell = new ActiveXObject("WScript.Shell");
# C4 {/ T* N9 V( G1 x
; F1 o7 S' V8 K R2 x+ gvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. W0 _' w* U% v' M$ }
% ~. O; e0 K b1 f7 ?simple.SetLicenseType("Runtime");
7 q& { y& [- x5 }+ o/ y J6 v 0 ~8 \$ S/ X7 E% ]& f- \
try 5 J3 G, h, }9 b7 R+ Z2 _
{ ( p, a# Y# C9 V \$ u! _
// Enter the path to a model file! 7 b6 u; r$ W" u% X1 {3 F
simple.LoadModel("C:\\Models\\Test.spp");
2 c* \% M- T7 ^( x8 J/ w} 5 c. M( A( g8 j4 C& n
catch (e) H1 H% Y8 D+ R! i4 Y& }- S/ l
{
& N* B* u' S5 [8 B1 H) e$ K WScript.Echo("Could not load Model!"); " @7 z1 P1 u' |* Q. e
WScript.Quit(); # Z3 w: r6 n1 l8 g
} , `+ u( D/ j9 C0 R m" K. h
7 p( \2 n) Z" l( o
try
X5 P v, [# ?{
s5 E( C ]2 D7 Y; w simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + N$ E' X! ~' N7 g( L- K. I
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
# g0 L; _1 B" G' d if (r == vbCancel) 5 R/ Y: o0 l( L
{ - Y& {5 S" h/ g. r ]7 L/ I
simple.CloseModel();
/ O, h9 J0 l0 C WScript.Quit();
: y3 ~& G# U+ E# z+ x( N$ @7 m } 9 [1 X6 z w: ~0 ?3 @# ]8 O+ `
} j4 g" B* T5 Y5 S, B3 Q
$ s! C, R- c, I8 ~simple.StartSimulation(".Models.Frame.EventController"); * o" G" H# f5 r* B6 s% y o
# i2 q( W/ s8 | |; U1 e
if (simple.IsSimulationRunning()) , q$ I5 y5 X, a7 g$ ?4 U
WScript.Echo("Simulation is running!");
) R# ] a' V/ [$ m6 x, @+ {# y* t 1 o! @% c2 Z$ K) l {$ N; W/ W! a% {
// Wait until simulation is finished 7 F* k/ K ?1 m4 N; U( K8 ^
while (!Finished) WScript.Sleep(2000);
9 ~. x. O/ ]$ E' j y" i7 i 5 G# W; q# `0 [3 w' \: J T
simple.CloseModel();
! k, \9 }4 u5 C( I) W: Usimple.Quit(); " L1 ^3 r# e' a! a# z* E
WScript.Quit();
5 v! I. G0 P+ w. w- q- R1 `9 c# l, ~$ x' ` " c7 }$ n) _1 K# Q6 D8 Y2 m. _6 |
- r, C: v8 q$ I5 p. R5 w: ?function RemoteControl_SimulationFinished()
7 D5 N3 K! f( t% s# h7 k- F5 ?( A{ 2 C4 ]; M1 t% [; e4 Q" k
WScript.Echo("Simulation Finished!"); |