Example of a JScript 3 o g) x( C7 b2 A" O% d1 H) A
var vbOKCancel = 1; ; }2 R! @$ v( t' v) C& g' f; @/ M
var vbCancel = 2;
( J f+ L6 f; r2 h# \% Fvar vbInformation = 64; S2 I) e$ _4 Z; m! K. C0 J
var Finished=false; $ Q6 T# ?4 E, {$ K$ D" ?
, W& b' d4 [6 N0 l; P1 N* x6 wvar WSHShell = new ActiveXObject("WScript.Shell");
' b% g* i9 [; S5 o. n, Y0 e# [ % f* Z. P5 S' B$ X! I+ r& n
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
4 U) L6 @6 {9 b, \8 |* K
5 z; g2 S2 K6 M( v: V4 m" ]1 Hsimple.SetLicenseType("Runtime");
9 i1 a) _$ s3 G9 J+ C- {3 W 8 A; S) }4 N' ?! U( N
try
+ t' a, v; Y1 _0 n; c{ 5 W5 e! j5 ]1 r& _, j6 F* J* R
// Enter the path to a model file! : a. ^1 b/ _/ Y$ K V/ @0 I
simple.LoadModel("C:\\Models\\Test.spp");
; H: r/ V9 z3 R% h) Z% Q9 ?} ' [# o. J# Y d6 U
catch (e)
% X9 c. l. S6 K2 h. e{ 9 `) L. {. q6 t; c
WScript.Echo("Could not load Model!"); , t: E0 O& m# |. e9 }
WScript.Quit(); 9 W6 q+ e5 D: p% r2 I7 G$ w
}
% @$ y1 B W3 G+ v" x3 \ / {8 {9 H( {8 y5 d# r
try 5 p9 h8 \/ u6 i# u9 I! B& R9 n9 _
{ 1 a$ ^, [9 M) H& ]' J! i2 k
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
( C% Q, f: y: z% ]) ~9 W7 N r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
- V! R5 A6 T6 q, Z7 g0 K if (r == vbCancel) % F" o8 `- T/ { L
{
' `2 L" Y1 F# }& P; O simple.CloseModel();
+ O" |5 g% h1 h) P WScript.Quit();
" {7 h2 H9 l! L1 J7 I5 X }
$ l/ e# q2 n) b' o( E' a! R}
* f+ n. E- z2 Z) U& H! ]% x$ b; B 0 e. M) [+ g/ i: D$ E3 j- v, L
simple.StartSimulation(".Models.Frame.EventController");
% G* R9 c8 `0 t2 L4 p' G! s
" y, k8 ^& q4 Cif (simple.IsSimulationRunning()) . s9 P. e' m$ P! v/ w$ H+ Q
WScript.Echo("Simulation is running!");
2 A; W( |1 m* J' o * f9 R | n) @) v
// Wait until simulation is finished 7 F7 O% }4 `! ]$ e" W! `5 Z. t
while (!Finished) WScript.Sleep(2000); 9 i6 r+ P! u/ L- r. v2 b
. G/ B8 }: V$ c0 Osimple.CloseModel(); # r' A9 _8 P- R# v. m& S7 K0 c
simple.Quit(); ! F# ^+ R3 G0 M3 h5 |, i3 Q9 K- U
WScript.Quit(); ! ^/ E- ]2 x4 _- Y9 n4 O+ j' C
- |- N+ ]$ g" w/ [
2 J: q( l& h: x- S( @9 L: g0 n" q) `function RemoteControl_SimulationFinished()
2 k8 V* B) a2 H/ r* t4 l. W% s{ + V) e2 Y/ d6 |/ j
WScript.Echo("Simulation Finished!"); |