Example of a JScript
3 ?6 K) A- E/ N3 e( ~# Lvar vbOKCancel = 1; 7 o. e/ z" H$ e7 p5 a. h
var vbCancel = 2;
, K2 O& _/ P- s. T- tvar vbInformation = 64; 0 Y+ V- `1 b: @& F, A, r7 x: D, o' v2 L
var Finished=false; 2 ?: O( _: f' y! Y2 Y! @$ N: {5 p
7 U G$ n B( Zvar WSHShell = new ActiveXObject("WScript.Shell");
' m1 O5 A2 f/ Y) ^
5 @5 v4 ~& w7 e Vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , C/ ~8 ~3 l1 H1 J' h
, J' |4 r; \6 jsimple.SetLicenseType("Runtime"); ( t. f; r5 Y% x
6 M0 ^5 w9 F6 n9 K; J& J( E6 x
try 4 Z, b6 B b2 y. v9 \6 P
{
1 c4 p- }! }: N1 P2 M* L0 M // Enter the path to a model file! " j% S$ K" n4 w5 e
simple.LoadModel("C:\\Models\\Test.spp"); & F+ |. f3 Z/ O5 i
} 3 T8 c7 q/ M+ c8 w
catch (e) ( A3 C! U0 A) Y
{
4 i! t- z& I* h8 |$ o( n7 S* H WScript.Echo("Could not load Model!"); 7 J [, D- N4 O
WScript.Quit(); 9 E! c. N8 E8 X5 R
}
1 q) x5 q; B2 o; w
. E" B1 b0 G4 x7 L6 n) s8 Rtry
9 w8 J1 C* [# U: u{ 1 ^8 l% Q$ f2 ]2 r8 u- @+ ]
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
$ h3 ?: d& R; S) S7 A r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 |( {* p0 f ^: q/ T& _/ { if (r == vbCancel) / M* u; X& H9 O* `. ]8 {
{ 2 {9 V; P/ h k1 I( c6 ~$ R! _
simple.CloseModel();
9 C# P) u- ~) x8 C; f1 t+ \ WScript.Quit(); ) @8 W# C& d% E& l0 N2 R
} . ]* _/ P1 N, B# T, W5 v0 O8 T
}
# S6 d9 }4 w) a1 Z* i' N" B- ~ # T- e) t/ P4 C* K" g" m
simple.StartSimulation(".Models.Frame.EventController");
3 N) E. F4 t0 l8 F" ^ , m# C; @- P! |0 B- b+ G: j
if (simple.IsSimulationRunning())
3 H3 B ^* D6 |4 O5 f x9 O WScript.Echo("Simulation is running!");
0 v7 I3 k2 f" D9 ^% `# z( _
4 w. ^5 i) V' V: ` K// Wait until simulation is finished
+ l& g( I+ {4 e( i7 c4 Xwhile (!Finished) WScript.Sleep(2000); + F; }7 m) `% `; \8 W5 v5 p
0 ^/ e' i+ U6 ^: ?
simple.CloseModel();
# E, \+ ?! P; @simple.Quit(); 5 g2 Y2 y: ] {1 w
WScript.Quit();
& `2 z, ?) Q6 s# m1 h! e
5 `" X; Q4 `- }+ V# n$ a , L) h* O" h) c. w2 A9 P1 H7 d/ T
function RemoteControl_SimulationFinished() l8 ^- T5 W9 k& W' x
{ $ s3 G+ V8 u* p0 `$ E! c
WScript.Echo("Simulation Finished!"); |