Example of a JScript
8 [7 j1 c% t; i U. d' |0 N, `% L# gvar vbOKCancel = 1; ! R& s# C5 N( d) E+ H
var vbCancel = 2;
2 t, C) A' J `9 L5 C, ^9 i! c8 kvar vbInformation = 64; ) Q5 i' U$ l* { U7 \" g
var Finished=false;
* X% ~% m3 p7 b
( z `2 Q% w4 Pvar WSHShell = new ActiveXObject("WScript.Shell");
F5 C& h$ w7 g+ E+ k
$ q1 I: L1 Z3 n' Dvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); b! v% }+ x3 H% D" a/ T" Q
2 R% l' d5 k, _( Qsimple.SetLicenseType("Runtime"); 6 X: H! L9 W, W& X
3 L0 S- w' Y' o I4 X# _: d
try , o! _) n, G" t' S8 |! _( G$ t; A! S# J
{
5 k K2 d. O$ i1 K // Enter the path to a model file!
, Q. Q3 x ^% q; Q# f/ e9 m6 ?) k simple.LoadModel("C:\\Models\\Test.spp"); 0 Q- z9 ^# t& n6 W
}
1 I! k/ T ^. g- S2 W/ L& Icatch (e)
, F; s# I$ \+ E{
/ u1 ]) ?+ q- g; w6 o5 p$ k WScript.Echo("Could not load Model!"); + o) ~' }* U, f1 K
WScript.Quit();
6 B) Z& }% V) @1 G/ x6 |, f5 `8 u w; `} : j1 E! d4 t; F0 l
F4 ?: `, o! l# X: d% Dtry 6 x1 L/ X+ h+ s
{
6 K* u( m+ @, x( ?- a& L; N simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # \1 A! D) j' q& D# r
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); , \$ w2 K1 x/ e6 A U
if (r == vbCancel) 4 g/ @* C; A" ?8 a* e
{
6 M0 A j) N* B* x/ P simple.CloseModel();
. d9 c0 I% ]4 Q WScript.Quit();
( l8 f; V9 {% U$ A2 R } 9 k. b' `% U& O0 @
}
/ e; C3 o! l; s+ X8 C# D $ u1 v' b4 \7 m- O4 q \
simple.StartSimulation(".Models.Frame.EventController"); ( g$ t! e$ ~* j3 C
% R3 ~" T: @, Uif (simple.IsSimulationRunning())
' u1 c7 |+ c* i% k0 E3 M% w WScript.Echo("Simulation is running!");
5 S6 W7 w% ?- c* |/ x
/ S" e5 H# e2 o6 {// Wait until simulation is finished ' Q2 R. _' l; _; X7 r
while (!Finished) WScript.Sleep(2000);
- y3 u4 j! q9 ]2 w8 S" T+ G $ {% M! ~4 _- Y6 G$ D
simple.CloseModel(); 6 y0 w# v# Z" k& p
simple.Quit(); , D2 U, u5 V5 ]4 F& r0 Q
WScript.Quit();
- R2 W9 A# h7 R9 U! @
/ m7 u, w' u. _2 _( y8 P
0 K( X ~1 X _3 p( Hfunction RemoteControl_SimulationFinished() r# _- `$ ^2 y, |8 ~
{ 8 v K' b1 r0 U I1 b* C
WScript.Echo("Simulation Finished!"); |