Example of a JScript
~; Z# B# a, y# kvar vbOKCancel = 1;
$ U7 T5 ?- o- p, f" b( W% y. c9 ovar vbCancel = 2; ; J( H5 Z* o5 N" k
var vbInformation = 64;
3 d5 r% P8 P Z! s ~var Finished=false;
5 ]* {/ g d u+ C8 i \
/ X& a$ k8 B6 k# e9 b4 _var WSHShell = new ActiveXObject("WScript.Shell");
6 c3 a% R* T9 {. `9 V7 ^5 ? 8 C2 J/ Z! q% y% t8 q5 j* |* L t
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
2 {, n& E3 B; U4 d
V+ {& T' Q) R, \7 q/ A' j Qsimple.SetLicenseType("Runtime");
o& t8 |! ~& \# s5 e
. c# ^9 ?5 I, y- Ytry 3 L; ^4 h- R& `0 W! v( f+ j
{
. B5 ?. w% ~9 Y/ I. Z- X. { // Enter the path to a model file! # R/ B# j! U1 ]1 m8 G5 l8 O( w+ g
simple.LoadModel("C:\\Models\\Test.spp");
! [: @) ]' t! l6 ^7 `} - Y4 ~* I) p! ~! g+ U2 }& g
catch (e)
8 T2 }7 S! v2 I# d5 ~{ . g, u( U. Y- l; Y, o- J
WScript.Echo("Could not load Model!");
$ o% p$ \, G5 p7 U q+ ? WScript.Quit(); 0 C3 ^' H0 T3 t5 k A3 Q7 J& }
}
. {9 }% ?7 y% f8 A/ w5 h/ ~' }
) _) V- {' G0 B1 x* E6 Vtry 5 E8 O8 X1 a! I: H/ G t+ W
{
5 Z+ ]' ^3 M) x, n simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { " K m) e' x# A- g0 ^( d# n
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); - g" f @2 ^, z% X- U
if (r == vbCancel) " a4 R& `3 x9 K) e' X f0 }6 n, A
{
3 O7 E0 F+ y8 X' l simple.CloseModel(); ! K$ |( K' l' i; n9 L: y' d9 \
WScript.Quit();
5 g6 u0 [' y4 p }
& k! m5 {2 L, K3 T3 j0 t}
& q/ Z9 N$ @5 C+ p/ i
* {1 p4 Y, E. T* S O4 A' wsimple.StartSimulation(".Models.Frame.EventController"); $ t9 T' a& g8 b+ D1 a3 A: Q, |
& @! i2 u* e! x1 @if (simple.IsSimulationRunning()) 2 ]) e/ Q- O3 [) q& e! E
WScript.Echo("Simulation is running!");
( Q2 r" p* \% X6 M. S4 D " s) O( V: J% t8 ~' i2 x5 ]6 u( a
// Wait until simulation is finished
! B" A! {: o+ k' Z& E r) U" _while (!Finished) WScript.Sleep(2000); % z, m8 r; }; z) j
8 ?# Z: R. `! i% b; Msimple.CloseModel(); ) ~5 B' D. r/ }# _$ ~3 K* Z, u9 I
simple.Quit();
" {$ {/ n+ `1 {; Y: [# `9 }& qWScript.Quit();
: q# V$ v0 O( s) |4 O * I$ F8 D: i8 X# s: m1 {
) F2 U- H- B" }
function RemoteControl_SimulationFinished() $ e9 D' d7 P' e9 _
{ & l5 i2 Y, o1 z- T, S* y3 q; m
WScript.Echo("Simulation Finished!"); |