Example of a JScript 4 ^- W2 M2 m$ u/ v2 J, r) z& L( g; X
var vbOKCancel = 1; * B0 G# k- A2 ]3 j+ X, ~- |
var vbCancel = 2;
, \+ {( [5 y8 S# _. vvar vbInformation = 64; 5 `2 b$ ~% l5 T/ `
var Finished=false; 6 o' [. X0 H% p- ?/ @
3 c; C' A& w9 s3 ?% I. W1 E) Y3 g
var WSHShell = new ActiveXObject("WScript.Shell");
6 t/ G1 ?4 C. K5 A. H $ e; O7 X& G/ V2 s
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); . Q; M# D( E- J3 o
; R$ i3 Z; p" G% `
simple.SetLicenseType("Runtime"); 1 d) @8 \/ }3 r7 l/ R8 i6 x
" M( n) z/ j/ u3 p5 d1 Stry
+ N" I. h1 Q: J' @" z& T{ ) `/ y- A7 P& V7 m! ?
// Enter the path to a model file!
6 }1 M% [* f5 ~: U simple.LoadModel("C:\\Models\\Test.spp");
5 @# N& \. ]0 [4 `, K}
4 [- w; i5 r) d6 x1 Zcatch (e)
! E% c' M ?7 S1 j M+ D' s, K2 Y{ * }0 s& `: i1 q z/ m$ f
WScript.Echo("Could not load Model!");
& m8 s) t; j6 D j7 i$ X WScript.Quit(); * i" A+ f" w# r: l8 V
} : o$ H( @% C. I5 l0 n f: P/ V
+ |/ I8 s( [$ M) o, Rtry 5 \6 o7 o9 h) x6 c
{ 8 y. G$ A X4 ^- y
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
/ R& l- U) d: I r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
3 K- h4 y& l, Q2 a9 b8 e5 Y if (r == vbCancel)
' H4 M$ @" }4 Z9 s' O0 F) ^ { , R, \8 q6 X! |! D0 w
simple.CloseModel();
) O8 O0 Y7 R* W4 Y WScript.Quit(); 7 c" f/ n4 s6 `
}
9 E- M. |' k; K$ P9 L5 ]; U}
% s) v2 l' w7 O8 v5 g
2 N$ p) Y% i& e2 Dsimple.StartSimulation(".Models.Frame.EventController"); # s9 i; A' R+ `2 X, K
, g, x( ~9 o6 N& p0 v* ]+ Q
if (simple.IsSimulationRunning())
0 o* v! N6 q( p( o. X# `' r WScript.Echo("Simulation is running!");
6 y* d- p* | E7 U) M ; d% ?- J* `8 E: p% h; |( F& Z
// Wait until simulation is finished
7 u5 |8 Q" j/ k+ n$ U" ]: G. b! Zwhile (!Finished) WScript.Sleep(2000); @7 n( W6 \2 T+ w; M
" J8 M6 H$ n( P" E/ s# r Q) K
simple.CloseModel();
& V5 |% s& E9 B" Asimple.Quit(); ' P" @( n# u7 r$ t2 o& X
WScript.Quit(); 4 r0 C A# y% \/ h" u' n9 m
P \. k' [5 u5 Q8 h. e9 b5 z # L0 N6 W& k/ ~/ ?# G) W& f# J' }
function RemoteControl_SimulationFinished()
! ^. \) Y9 t2 S) d \{
: Z) D. R6 J. K WScript.Echo("Simulation Finished!"); |