Example of a JScript " Q/ X P' j9 B0 t& R" ]
var vbOKCancel = 1;
6 R# f+ N/ H0 ?( M" b9 hvar vbCancel = 2; 6 P) [4 o- o: h! b$ h# k5 N
var vbInformation = 64;
% T2 Z: Y! l( j, svar Finished=false;
& V, ^- u9 S O' h
) P% t. K1 G' i$ P/ I) xvar WSHShell = new ActiveXObject("WScript.Shell"); 2 x4 e, l) z, O( g
, A: W3 F% U/ `9 F4 x% ?: bvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
7 x6 I! Z- a+ D6 ?* y; c
* q, J) |0 Z. ]. R( Vsimple.SetLicenseType("Runtime");
6 |& D r- x2 N% E: f& U9 O4 h # E' n4 k* k) b u4 _( M. g) \
try
$ r; I; g$ W+ V" ]/ r: R- a! G) s6 O! E{
1 U- F; J2 q4 G( U+ F9 H! J$ f // Enter the path to a model file! _/ Y$ Q5 l8 m/ f4 K
simple.LoadModel("C:\\Models\\Test.spp");
6 a; c& g4 l# G6 U6 M} 9 P4 d' p* w F; Z; k
catch (e) / I! J4 K# t6 k4 O
{ 5 X8 E2 p1 y8 v( R; `
WScript.Echo("Could not load Model!");
. }8 L2 u# n4 f' i; \* L1 l WScript.Quit();
/ G* P9 ?# I7 Y) M- g}
4 X. K$ a/ {, s0 k6 S - ~/ E$ f6 v! p* [/ ~9 N
try 3 y, d8 V. P, |3 S; L
{ 7 q9 x' ]! l& m( e6 w6 | h
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
6 H3 U2 Y/ d! f+ A8 b: P1 Y r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
! O; N: _9 r7 W' L9 n/ [ if (r == vbCancel) / z0 G4 Q! E0 e" U8 R7 I7 p
{
! w$ r1 c) W/ K% X( N simple.CloseModel();
0 w3 U% ?8 s$ ^0 C# j: Z$ q WScript.Quit();
- R% C9 ?0 v: ~# E( @ } ) `$ [# }2 b# `4 g
} " ^. b& z6 X( ?8 m
5 {+ {. o! K4 Z8 l
simple.StartSimulation(".Models.Frame.EventController"); # n: u. R; H) d* [5 s8 f
5 C8 B: ~2 X8 K% P1 Zif (simple.IsSimulationRunning()) ; L& h2 q; C+ P3 |0 A9 K: g
WScript.Echo("Simulation is running!"); 6 g9 t" ]; X" q. p C! ?3 v. T4 a
: t2 g# `2 ?0 j// Wait until simulation is finished % D5 z) t( |6 m- N
while (!Finished) WScript.Sleep(2000);
1 S9 E3 N8 S- g1 u4 O4 |. C& a ' o- B1 \) j, E n/ Z( R$ i% ^
simple.CloseModel();
1 o4 m# }; |" r1 Z5 U) ]simple.Quit();
9 k: h2 ?' u7 k6 K4 }WScript.Quit(); * D. K J/ N0 L4 L* l. i, \7 U7 N
B" n( b6 R1 m3 P, _ 9 ^0 l" }8 ]+ S8 j
function RemoteControl_SimulationFinished() + W9 e% `6 y. l; U; G0 I
{ ' Q$ A. ^5 M2 W8 r4 t, w! O
WScript.Echo("Simulation Finished!"); |