Example of a JScript
2 P5 V& ]' h/ v0 Dvar vbOKCancel = 1; ! T% O1 T! g% Y5 \% G
var vbCancel = 2; ! P: D: k" f& x7 R# d7 e0 D
var vbInformation = 64;
5 q0 n$ S* M* v3 }( t( Xvar Finished=false;
, e. b& N% G% ~ W5 w: l5 ?
1 \5 w2 {& N; u8 }) f& K2 V7 R7 zvar WSHShell = new ActiveXObject("WScript.Shell"); E$ k% O+ ~% p& A' d
; B+ y; F# V* l% n4 F. w4 w( Y
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
# D/ h( W: s! Y1 K" {
( R. k$ v1 u1 b# W) a1 f7 ^1 Ysimple.SetLicenseType("Runtime");
* d- [, c! x: l+ v! s# x6 g
" V+ C' J4 N" o* Q; a& t* [5 e- ktry . q1 n/ B4 }+ `* I. K
{
( A+ }) S8 R- |: U+ E8 ^1 J/ a // Enter the path to a model file!
& x0 S9 I. a/ K# k simple.LoadModel("C:\\Models\\Test.spp");
. ~( k' ]6 |0 j: Z: L}
: M- _ ]& m" k1 R. |* zcatch (e)
6 I6 R8 B2 ]& m) Z& B5 C{
- b$ F1 P$ x, \- ]# N2 \. U# D! B9 t WScript.Echo("Could not load Model!"); 4 x; p5 f( P! k# H
WScript.Quit();
" k% @' O. _) E! D; g6 U, l, s& B}
# t+ y3 e1 ?& s; v4 q 2 h, V2 w5 Q. A U5 }7 p: R; M
try - Y* K* X; D/ M4 o7 [
{ 6 ~" a9 @3 X% o& {' D v5 k9 S
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
" i# `5 }8 ]* s' { r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); / v; y( M. N) _) O% M
if (r == vbCancel) * j* ^: h( p6 b- @1 a" i
{ 7 E @5 B/ C# s4 N1 I& A4 H2 x" S g
simple.CloseModel();
- E8 [8 @- X) ~% @" Q( d7 v# _ WScript.Quit(); ) X! h) ?- F7 `7 U( H! m
}
, E/ |& q+ `0 K}
6 z" O0 F6 A' l* X0 @: {' y) `7 y 7 w- V3 m1 u! U% M+ v6 r
simple.StartSimulation(".Models.Frame.EventController"); P1 m; ^! G/ @& M) {
! k" z% k: H! e8 N' b& |
if (simple.IsSimulationRunning()) # f* m9 Y* A x* T. A) ~1 g
WScript.Echo("Simulation is running!");
' X6 j1 N6 P3 `
; x1 D. E4 K1 y; p# E// Wait until simulation is finished + h% W+ b9 B3 C0 e1 I2 P' v* T
while (!Finished) WScript.Sleep(2000); * {! \ `- v, H# C1 [' E
7 Y% b+ q `/ x, ?simple.CloseModel(); % i' R3 U6 A. b x0 o& @4 W
simple.Quit(); / V% k8 m/ t8 v3 H2 E8 K5 L7 t% ^" k
WScript.Quit(); * i& m+ ~. D( {& a& k$ e1 Z/ s
3 Y1 U3 i1 ]. I5 e $ x' K. k5 Z; x' Y! O/ w
function RemoteControl_SimulationFinished() & H: a4 X# ^, p8 }5 u7 j
{ 4 }2 ^8 y3 b' I$ |
WScript.Echo("Simulation Finished!"); |