Example of a JScript * \ v/ S l3 O, c
var vbOKCancel = 1; $ q# y1 k& E9 t# q
var vbCancel = 2; % n* R( R; e8 Z1 w
var vbInformation = 64; 0 U% w6 e* ^ _: R$ a5 V& ]- S
var Finished=false; $ e+ l, S% |% @5 f4 b- n
$ g" N( V( l9 H, T; W9 ^6 lvar WSHShell = new ActiveXObject("WScript.Shell");
# O# O& ~0 y1 d# w p: A- g& U
% \- f6 W. {2 Y0 Vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 S t# `1 K s0 s) Y
+ U1 G- n* H& O
simple.SetLicenseType("Runtime");
, o" u+ V% g+ [7 E0 g
! L% }, Z! c3 |$ z, gtry * ^& l9 e9 h! b' Q9 V
{
) `2 t# n! _- ~2 V4 a7 Z // Enter the path to a model file! ; a' p8 w) P" R; p
simple.LoadModel("C:\\Models\\Test.spp"); * g) j3 {8 ?% X: D
} & S$ f7 [! h1 n- ?' a# J
catch (e) $ Q0 K/ K9 E5 E/ c! L L
{ 4 M: ]- y4 H! j+ @4 K6 l A8 m# f
WScript.Echo("Could not load Model!");
4 _! O+ i7 Z9 \4 A3 l8 k' K( l' c WScript.Quit();
6 C& ?, O$ S: t( l: q}
! l! X/ S4 \$ {0 @. T % w2 W6 \4 w3 Z5 n! }5 j- m
try 9 t9 c- D* A- q& _- e
{ , t4 z. C% g" L8 v0 n
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
! i8 D" }6 Q0 q- a1 O9 j4 u r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
V/ i0 q/ e5 K9 U; s% z if (r == vbCancel)
" n+ g1 s @% y {
2 n8 [1 T$ [. R l( i+ K/ Y+ i/ a simple.CloseModel(); $ X% l. g1 r1 X9 C& D4 ?
WScript.Quit();
9 U/ P" c! N! C3 w9 K: R. ?, ` } 1 A6 Q: e3 G, a% f+ a
} 4 g9 u5 w2 g, B+ Z9 B8 g% o ^
- }0 T0 Y3 O; l: n( W5 o& wsimple.StartSimulation(".Models.Frame.EventController");
' X8 X- ? C7 w( U
4 H# ]1 J' E" @0 ^2 Sif (simple.IsSimulationRunning()) ; c- ~0 j% r7 v4 L( D
WScript.Echo("Simulation is running!"); - q: A& j0 ?) L, }
7 M! Y6 b1 W# q$ @// Wait until simulation is finished % @9 }* |, {1 D7 A- o3 Z' I
while (!Finished) WScript.Sleep(2000);
8 [. a1 e; R. T6 \/ j0 A4 i% F2 g) p - \5 W; |6 h1 }# |
simple.CloseModel(); # ] O- h* \! r; i! @
simple.Quit();
7 r, N& E$ A W, `( ]2 s9 ~5 D# SWScript.Quit();
# G" c: Q3 `9 o# f' i6 ?
6 k8 S0 X) ^. }9 C2 B
4 F/ f/ z( I. _( G- U- H( f* o0 jfunction RemoteControl_SimulationFinished()
2 z0 v+ ^; ~1 W2 p: s! c{
- C9 D5 u$ Y w4 p$ S& ?: e( r( l WScript.Echo("Simulation Finished!"); |