Example of a JScript
! k9 u$ b3 Q& a" F! |var vbOKCancel = 1;
: P& j3 O* j/ v, s Dvar vbCancel = 2; / s' Z0 o2 d7 q! K7 ?& @. @
var vbInformation = 64;
% W& p) h- g8 }8 a1 t- Qvar Finished=false;
9 H" e& _9 f+ t
1 e, C) `& L& T3 N9 I \var WSHShell = new ActiveXObject("WScript.Shell");
5 O/ @) @. W7 [' s" ^' `- Y 3 n$ j) B; d# g3 e6 T
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ! _, Q# \% r8 c3 l6 [, }% t
9 B+ F/ S9 |# J" H7 \! y3 |; ~/ ~
simple.SetLicenseType("Runtime");
& l; R; ^1 c) \- @. \! J3 T1 } 9 h+ |8 H6 a5 Q
try
' F& n3 K$ c" A+ f/ l$ o{
& t! B' Y6 \3 `% K7 B _ // Enter the path to a model file! 3 X# s5 h9 H% z" D8 Z! t2 e
simple.LoadModel("C:\\Models\\Test.spp");
# |& \& |5 x6 R+ {3 w} 8 i& h! N) E, x8 g4 }, j6 y
catch (e) 2 s w( A, m/ [4 W5 r
{ 4 _! e6 l% R* ^0 w' I
WScript.Echo("Could not load Model!"); : R3 f8 Q/ }1 Q* n
WScript.Quit();
( b$ `2 f/ D7 G' p! l}
- h! E' P# D6 U3 `/ i: @" Q
) p; t: \4 W6 L$ V! t8 wtry
9 U% ~5 M+ ?* b! d* t6 y, T; a{
6 a9 a9 }( x4 _6 Z( q% e simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { - M& U5 e6 Q9 k8 m" c
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( v: c+ { W4 P1 p4 D& X
if (r == vbCancel)
% Q% `! n: H9 O& ?/ X6 k" O1 m6 Q { - Q7 @# ^: m" K3 O& [0 a) @8 z
simple.CloseModel();
. y$ M' k* t s WScript.Quit();
! Z& } @0 s" P; H } % y7 ^ f; n1 j* r& \' H! W
}
; I# _5 z* A5 p* v6 H. S . J( v' i% ~$ s7 _4 m
simple.StartSimulation(".Models.Frame.EventController");
: t* W k$ R' q9 K% G1 M % V) ^; z p2 ^
if (simple.IsSimulationRunning())
4 G8 N, _9 N' O: ~# p4 u WScript.Echo("Simulation is running!");
- J: l0 e) Z: y/ `8 X# C+ G4 }
3 q1 l: Q5 S7 a f// Wait until simulation is finished
" J% x A2 W3 X5 qwhile (!Finished) WScript.Sleep(2000); 3 j: |7 c; u/ @5 S* A5 E& I$ E
8 W" s1 r, q0 h) i% N4 t
simple.CloseModel();
9 j5 k# M' P8 a4 v- @5 xsimple.Quit(); / ?0 B9 O* N9 G% x- Y
WScript.Quit(); * K1 P+ A7 F$ n6 L, P8 \
* V# r8 c5 S7 B 9 v8 s$ x/ ~+ e- U7 V
function RemoteControl_SimulationFinished()
( p+ g) ^$ x' ]{
1 _0 S, ~/ w# @' t WScript.Echo("Simulation Finished!"); |