Example of a JScript
7 l8 y }( X5 R9 j; Vvar vbOKCancel = 1;
4 v2 ?6 d* n( N$ D6 B; }var vbCancel = 2;
* w8 l* P m. _var vbInformation = 64; ; \3 o& N( b" c7 D, y" r
var Finished=false; & V' X. [ x2 S1 I2 |6 j/ W1 V" `
% ? }" @, x; ~ L/ R5 m1 c# M
var WSHShell = new ActiveXObject("WScript.Shell"); ' w* \8 @) {5 z5 f9 U( Z# Q
! `6 S) V7 b: w- k' B4 J5 V
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
$ D, M. h' P% H9 }( a4 ?
% {8 ^$ _) ]# V! U. b. U/ b# W* Lsimple.SetLicenseType("Runtime");
& N1 M7 [3 J- y& c % `- G/ G0 j/ }% R3 |
try
# f9 H6 e) ~4 R2 n6 {- |{ & L. z6 K3 i2 A
// Enter the path to a model file!
# i* a E/ O' ]5 y- \% b simple.LoadModel("C:\\Models\\Test.spp"); / |' w `. l+ ] a
}
. W, q M* O: Icatch (e)
- `$ }1 @+ |5 @% p1 S{ , e: G- }/ g p8 g: ?
WScript.Echo("Could not load Model!");
. X% z$ @$ V# \# w M3 k* a' l WScript.Quit();
* h" v& u# g$ Q}
, f6 P( n6 H) Y' u+ x " n, E( n9 }5 z& G
try 6 o3 {' P/ V4 v+ f8 s' p0 S0 X
{
2 S y+ m) [8 L* m8 k( j simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { % L3 R$ f) w$ }0 {8 g" K9 h
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); / z# _: M7 ^& {, O7 q- z
if (r == vbCancel) 3 P$ b3 p' p) K# y
{ i* P3 ^, w. n
simple.CloseModel(); . b: c( C) k j5 R, f' P, B
WScript.Quit(); % w `- N; \) H; S, Z4 x8 K8 m+ U3 v
}
( \* g( P ?7 U/ M- H}
$ E5 F; w3 p: T# j5 @) w, \# f + l9 Z* D' a$ m9 `8 h
simple.StartSimulation(".Models.Frame.EventController"); / J$ p2 h% c9 {- e: E) `
" {" K/ B+ d. Z# k' T5 l* o5 uif (simple.IsSimulationRunning())
% |9 e' ?& j( Y* l" u WScript.Echo("Simulation is running!");
! j, B0 y0 ]) l' _: s# W, L
. E# B& Z) z2 k3 g0 O, s7 m' F// Wait until simulation is finished 3 Q' c4 R7 M! K; q: l9 F9 M
while (!Finished) WScript.Sleep(2000); % M! ~6 q6 M' T7 s+ S
# E7 g' {/ f: n: wsimple.CloseModel(); ! z5 l& Y! D" U- V) }- E7 H; K
simple.Quit();
( Y' E, X+ S; f/ g9 u9 N: PWScript.Quit();
, E5 ~* y } t5 h* k0 ?! G
) [( Z1 i2 o6 v0 x+ `: R9 ^- B & |3 h: ~2 v. G* _6 n8 h4 h
function RemoteControl_SimulationFinished()
3 T' F+ @: k5 a& m! \( C$ k9 a{
7 p3 `3 ]% f6 a2 b* u# M; t. w WScript.Echo("Simulation Finished!"); |