Example of a JScript 0 [+ v! |) O$ Y7 S' c' H P9 x+ e
var vbOKCancel = 1; ! \% s' R+ Q5 x" ^
var vbCancel = 2;
$ O; C- S6 d% C( ^, Wvar vbInformation = 64; V/ m$ k( v# N' [; M: B/ i
var Finished=false; # V M' }) D9 C: E& t, I1 F
5 w& ~8 i0 D! U6 d2 {6 ^8 o" J0 @
var WSHShell = new ActiveXObject("WScript.Shell"); 7 b4 A M H. R; `1 L
- z+ s, g/ e" t( Z
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
& [7 E: P) r# g; H
2 j( p, @2 `% K) E/ o( N8 Y6 Isimple.SetLicenseType("Runtime"); 5 }+ E/ s$ C& t! I# L
; H5 S6 o' b' ^1 k) Etry
6 d" u5 i, N1 d. W) Q{ . W: t0 A+ t( R- Z. l7 d0 W$ B
// Enter the path to a model file!
( W2 y1 T* w3 R7 d8 M! Z) } simple.LoadModel("C:\\Models\\Test.spp");
$ b9 H' ^# f9 t1 O}
: u, Z: \8 r# `( n& U4 fcatch (e) % A/ P3 \# f4 ]1 Z
{ 8 d* a& U) ~+ M/ m. s
WScript.Echo("Could not load Model!"); 1 v: s. V1 B1 @+ L
WScript.Quit(); 9 R+ g% V9 C: B6 [* x( T
}
E( T. Y8 T* R; O 4 Y( W5 j) @; i0 [/ Y/ Z c+ g& W
try
% R+ M; v- \, u$ _{
8 k+ W* f% V# C D7 T: U& g simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { - c* t8 I8 x+ Q, I
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 q, F; f% K: t: K
if (r == vbCancel)
5 K7 m T7 I6 o$ O { & i0 y" K: p: Q2 |$ O+ c# C
simple.CloseModel(); $ J# x }' `! @8 B v
WScript.Quit();
% p8 M8 z$ [2 u: W9 d; J } 4 M; c- y& a( I3 V% W% m: N
} % }% x# g/ A2 E1 X1 X# ^
9 o9 m$ k* {' N' Y! s
simple.StartSimulation(".Models.Frame.EventController");
; O. B' n" p2 n: O1 O6 P8 l& V ' T8 m. n! k/ A! S
if (simple.IsSimulationRunning())
7 l4 R& Q, T7 x! a% C WScript.Echo("Simulation is running!"); u, U! O. G# S2 N: t, {( J
& P4 U2 E- Q0 a a5 b1 v8 r// Wait until simulation is finished " P+ {/ q/ i S6 V
while (!Finished) WScript.Sleep(2000); 9 i g# H6 h& g
/ `) |" W% D' [
simple.CloseModel(); , Q- a& z8 R( f) c, z
simple.Quit(); 1 N% A9 l7 T7 G: @! ` A$ Y Y
WScript.Quit(); 9 U- E) B7 i+ t- U) x/ y# h7 M: b% H
. S, }4 u8 n& E O5 X& F$ j* `
5 e1 H4 D1 e% I' N% G4 A" e4 Cfunction RemoteControl_SimulationFinished() ! C( x7 e% O2 F; l' o# y1 c
{ ( M5 w' f5 y1 E* y5 t
WScript.Echo("Simulation Finished!"); |