Example of a JScript
/ P4 M* c2 Q5 H$ Avar vbOKCancel = 1;
" }# ~6 W/ M: U. d \& L7 yvar vbCancel = 2; 9 G, Z$ Y8 K5 L7 |1 Z
var vbInformation = 64;
5 J( Y1 u, U8 L- U" v0 x+ Dvar Finished=false; ; G! K, d8 O y( d9 ?+ q- Y) G
3 L+ g" ~( p# t! Jvar WSHShell = new ActiveXObject("WScript.Shell");
1 Y5 e3 o R& k+ q& S. u; O
" p0 t' d! L! v; Nvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
9 G7 y5 q% O) K
" a9 F7 {7 R* W/ i" D5 }# B" r+ R0 Bsimple.SetLicenseType("Runtime"); 2 U" Z8 Z3 ]: C% Z1 u4 z* N; O! c
7 U" l# y' Z- J' n) f- u4 Btry
! U h- S/ F* V1 P! V" o{
( F9 U; g3 O+ V& y, o5 [ // Enter the path to a model file! % W" r A4 [. W+ J j
simple.LoadModel("C:\\Models\\Test.spp");
3 G2 T7 O/ C- C @; C( s7 w+ q} ) S# V) O. B5 n7 H. I# `
catch (e) ) h& H+ G, e1 }. x
{
/ d7 E$ {5 F. `7 h/ u' `" u* U WScript.Echo("Could not load Model!"); 5 ~$ U f* ^8 p+ G' I
WScript.Quit();
7 q2 X4 p) F; |0 n# a" S} + W. P- ~3 v, g) B/ L: [4 z" m
0 K. U, ~1 d" d3 m( [
try ( @. I, H% x7 g6 E9 o% v: J* K
{ ) S" x# g) f# v }! [6 h
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 b7 O5 B3 L( U
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
7 F, {* Y0 p0 `/ t) n) V if (r == vbCancel)
* N2 O# y1 J# U" b8 p' l. i {
2 C9 P/ _ ?( t simple.CloseModel(); * J Y. l9 F8 \$ |- v0 D) W- p& R
WScript.Quit(); - F+ X, R I+ ~" H/ M8 ^
} . K7 \( P( u2 K
}
' J; J4 T4 T& x2 C
' Z$ l% b) j+ {3 M$ [4 `simple.StartSimulation(".Models.Frame.EventController");
" ^" t2 B" x) g5 M! o
4 s, ?* f2 ~; m. n4 i) ]) Kif (simple.IsSimulationRunning())
1 U, ~6 V5 a) p3 N WScript.Echo("Simulation is running!"); 8 N( b% M, e; W3 R3 B$ V ]* o
: E5 e7 Q+ M0 Y5 _// Wait until simulation is finished
# O# P! ?8 ? z! a6 xwhile (!Finished) WScript.Sleep(2000); % H; } I n( C" U
, V, E9 \! f5 n( g4 J9 Qsimple.CloseModel(); + D; k4 w2 d3 r, N3 l3 P' x
simple.Quit(); + I0 z5 D+ e! W9 s" d' k
WScript.Quit();
% M0 W8 n/ f; }% d5 P
" N( _! {' n$ x$ s( N$ e 4 T, w" B% U b2 F0 K$ I
function RemoteControl_SimulationFinished() 1 F, q" P9 t8 d
{
. E' l2 B" U5 j) b% e WScript.Echo("Simulation Finished!"); |