Example of a JScript
6 I0 ]1 d; ^" gvar vbOKCancel = 1;
+ {% ^1 ], R0 svar vbCancel = 2;
; k7 {* |2 Y. d9 lvar vbInformation = 64; & J2 v0 S2 O) u) U) p6 e
var Finished=false;
9 f% N- c5 M' y/ K0 k( R 6 d9 E" O! G. x* q
var WSHShell = new ActiveXObject("WScript.Shell"); ( D3 [9 D: {1 U6 ~2 ^& E9 R+ M/ b2 Z0 ?
3 l$ l4 F5 q" B4 K$ F+ w
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
/ k, \% p/ L1 A! z9 ?9 {0 [0 [ 9 a* m4 r1 s/ m6 @" N* b" |
simple.SetLicenseType("Runtime");
0 J3 Q& d; x* @/ u u ' O, k4 H, V" [1 J
try
5 I1 \7 l3 J. @, s0 H# @1 U{
9 D$ D; o0 i# v // Enter the path to a model file!
5 _ Q. ~$ E. A& w simple.LoadModel("C:\\Models\\Test.spp"); 7 o) ^& ^5 m/ g0 z5 p5 R4 m3 {) C
}
0 x+ M# ?; @8 [+ p8 Fcatch (e)
8 z: N+ T2 ?+ I* r3 X. W s{
* [# X; u ?" b: c \- ? WScript.Echo("Could not load Model!");
r4 u1 U# T& Q& h( |' Z) z WScript.Quit();
0 U/ q2 d. R* T2 {- O* [( e7 F} $ s) G/ R) @6 T/ z2 o
+ I Y+ L6 \% H w+ Vtry $ V# }" P, _6 F# y5 P/ O0 K% x, J
{ . D; I5 X; E) b4 c3 V
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { $ B6 d1 g9 a$ U" V$ Y7 P, B
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ! u% k9 J g+ }$ q# Y
if (r == vbCancel)
. d8 Y$ x4 l- b. L* R% V. V/ H {
q0 ^0 `1 W4 \( G3 N' i simple.CloseModel(); 7 c( H5 Q- d2 L5 y4 N" L" O
WScript.Quit(); 8 n6 k$ ] d- U' D% ^
} " X0 W, T+ |0 M7 l
} 4 i% f6 x3 w' Z; n
9 ]9 q: A' Y0 P1 p9 Y2 s5 ssimple.StartSimulation(".Models.Frame.EventController"); 4 O! J, i+ o8 v0 @, i* X! g
) a8 e# ~" b g$ k4 c
if (simple.IsSimulationRunning()) " o3 s- f* g# n; d9 U8 |+ i9 q) \: h
WScript.Echo("Simulation is running!"); 0 b3 P# j. U! \* w' N3 B( c. T+ U& ?. L
9 X/ V0 |. c+ {5 H& W
// Wait until simulation is finished
' `9 I S0 b7 w2 U/ g0 Vwhile (!Finished) WScript.Sleep(2000); ! H# q) d1 r4 z" ?9 `
+ r9 m6 L/ b# `" A
simple.CloseModel();
& |& P$ p3 e6 |( H: fsimple.Quit();
, q) Q5 m+ c9 ?) q7 G% }7 kWScript.Quit(); & S1 l9 W9 V& Q- B- k: s
j$ |- l5 W# u: C& z7 q 1 w) t* S @0 I1 k4 q5 A0 c& X
function RemoteControl_SimulationFinished() ' n/ i: }$ N! ]% K _* _+ _
{
, g- _ g) i: ?/ j WScript.Echo("Simulation Finished!"); |