Example of a JScript
6 P% ~& N0 M+ x# ~5 ?3 vvar vbOKCancel = 1;
8 ? p0 I+ H7 R c' i* `var vbCancel = 2; ! s. u+ }! n1 L% O5 H" `/ m- z
var vbInformation = 64; 8 I& g# \2 r) U8 [
var Finished=false; 4 W$ F" N4 o9 W& f( ]# h
) Q7 A+ F4 S: ^7 s5 H
var WSHShell = new ActiveXObject("WScript.Shell");
" J X5 Z6 b3 `& }* _6 s
& P: s; \& [" J7 C& x/ X0 evar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 6 Z1 G+ Y1 k* j- _5 E
, c6 v# E& I9 Q' s! [( Xsimple.SetLicenseType("Runtime");
, A/ } j1 L% N1 L" c W4 a ' n ~- Y3 y3 x; e. L
try , Z2 T& d* @+ V' u
{ , v. P3 K3 R# |! j! j/ c" N# L7 N
// Enter the path to a model file!
+ Z. \. g+ i/ e' z/ n) I/ r simple.LoadModel("C:\\Models\\Test.spp"); 1 [- _# j$ w) I/ s6 b2 j
} 0 S/ {; i$ M& s* I8 l; G i
catch (e)
$ [) _/ v& Y _' l{
" P8 L8 c$ X- a) ~5 C WScript.Echo("Could not load Model!"); J% l, v/ ]& n% A, |, Q& [
WScript.Quit();
; f: G" g) E" y} 8 o; D6 c) u1 R) o2 x* F, `
# w: i5 ]9 L2 X: U& l, Vtry
, a- o3 p# X( }. w) s. s/ F; x{ ! o7 W6 n$ ~) |/ c; x& ]& G
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + G) J* O2 @- D1 ?
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 x. o6 {3 Y8 f. `' g8 ` if (r == vbCancel)
- Z* T0 `# T( G0 ]' f( D: I { 4 q8 o, X8 x6 L8 J
simple.CloseModel();
, l4 W7 ^7 D6 j- Z2 j7 @ WScript.Quit();
+ J& X4 ~3 T& s' A4 E" \5 F6 x } 2 t- D3 s' o& ], a( y( ]
} - P1 P( B* @( o }; a' j3 Z
5 }6 I) E& l* K& j3 h1 Z5 E( x
simple.StartSimulation(".Models.Frame.EventController"); 2 [1 c& u: b( P* L! { V+ c( E& [
* P. {5 t0 z* Z" N
if (simple.IsSimulationRunning()) / K* H4 v# v$ t# V( U
WScript.Echo("Simulation is running!");
3 t( W% y/ _9 u( o- z5 u, c 6 `2 P" k. `; ~; ?( m, {" z5 P I
// Wait until simulation is finished
# d1 k z: j' r7 s! A* b8 h( Zwhile (!Finished) WScript.Sleep(2000); * E/ P/ y2 u* S2 P; {" Y$ e$ V
' z8 y8 r& z7 G
simple.CloseModel(); & ~! y* @+ W$ B1 l7 S
simple.Quit();
( v* m8 }' o8 O( ~) j3 TWScript.Quit();
- F- W) K; d4 l9 a+ A
& F6 Z% @$ g: h9 S
9 M6 o q, `: A$ xfunction RemoteControl_SimulationFinished()
4 e4 @3 q9 p4 d+ N7 x{ " k& G+ W3 Z/ O
WScript.Echo("Simulation Finished!"); |