Example of a JScript
7 g: z3 v d$ }1 }9 p/ svar vbOKCancel = 1;
! U9 m0 h, G( Q8 yvar vbCancel = 2;
( `$ t# z- \; o ?( Q% I/ K) _var vbInformation = 64;
4 _! E) q. g7 Wvar Finished=false; ! l. R8 K- s3 Y& u1 K
9 b0 l+ P0 ~2 Lvar WSHShell = new ActiveXObject("WScript.Shell"); ; E: J9 X( C& N
. j2 r$ J5 T* n3 L' {
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. w- z# U+ T2 K& _( |
5 Q; o; W) X6 X0 t; W' }7 gsimple.SetLicenseType("Runtime"); , Z; b9 ^# {* i6 a
: t' R" D! ^7 ^! G4 X* [, V
try ! Q' e i7 n9 {9 m( z' f9 b4 C
{ * h2 ?7 o2 X6 ^( C
// Enter the path to a model file!
2 i# y/ F9 s! a simple.LoadModel("C:\\Models\\Test.spp");
+ d5 F# M; h! o$ |$ b" U1 c}
2 O! r0 p$ r% x0 Icatch (e) & B+ ?* L, l- ^: D* {; R
{
, B4 {( n. m2 r1 w U2 n$ p! K WScript.Echo("Could not load Model!");
l2 d$ C" n. S# ^6 s/ R WScript.Quit(); / x3 G8 F! K/ h
} 1 K( H# Y9 G& q8 ^; r$ h( ^; c: C
" ?% ?1 b1 Z7 w9 O$ Y/ }+ Xtry 1 V: n$ d% q) i' D2 ?
{ + h3 A, H/ s8 p' A# x3 r. N; l% w3 M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
, ~6 R5 B9 j/ ^; i r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
- [) w$ c. h* ~! }$ m if (r == vbCancel)
& C6 x* Z7 ^4 q+ p e {
( Y7 [ ]# Z6 k O: {4 F# N; A- z simple.CloseModel(); 4 F* c' W' u, Y$ Y( @; q- o) f4 b% A
WScript.Quit(); * E, V! v6 w/ s( }8 d9 w. R
}
" R/ ~* t- f) H- Q X, s$ V}
+ V1 D8 f/ r7 D7 k8 N: b' l% M5 [! `
# t8 G% n+ f n' B& \simple.StartSimulation(".Models.Frame.EventController");
0 p) W, F/ l. c+ r4 w/ Z) [ % V2 |% g5 [, _5 A) N; n" u
if (simple.IsSimulationRunning()) 1 D4 t3 u' ^! S3 ?- i1 _' K
WScript.Echo("Simulation is running!"); ' b" f0 }& j3 S
! `- z0 B, [1 @) i// Wait until simulation is finished
# U: l/ @ B# o2 k4 Jwhile (!Finished) WScript.Sleep(2000);
- t9 X o8 k- E! s% ?% `& U 2 @1 x4 w: H* i" h
simple.CloseModel(); % Q5 y% ?8 D: e% O) @9 S* T
simple.Quit(); 8 X) E* o, l2 ?0 P
WScript.Quit(); 7 k3 L7 v2 V( l' |' h
. Z- y! Z2 |$ U( g% t$ E0 }
- S/ m/ F! m2 U o- }function RemoteControl_SimulationFinished() & W7 N" z+ @1 p
{ # q* K5 A9 A4 Z# q3 a1 w. P
WScript.Echo("Simulation Finished!"); |