Example of a JScript
- _6 M: C( I& M. ]var vbOKCancel = 1;
# D5 c! G4 `; b/ F8 @var vbCancel = 2; 2 e( p0 V( t8 S0 w
var vbInformation = 64; 7 Z9 @& e- [; w$ y& e
var Finished=false; ! e( t1 {6 d5 W# S& k, B- E
" t' x/ T* e- l% c( \
var WSHShell = new ActiveXObject("WScript.Shell"); / k+ @ ? [6 z& A, ^
8 Y8 W. x4 G. L% t# `" s
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
! S% {9 W$ j4 D3 B! A1 C
$ e3 R5 H8 m8 v2 P! |- bsimple.SetLicenseType("Runtime"); " @: S1 ?, R6 s" b" ^! W0 q8 K$ @( }
/ s8 _1 `5 I) e3 M: ~/ v6 Y& x
try
' `: ~8 D" B l$ ]* h) J! a, v{ 3 G X3 b& T$ |6 {
// Enter the path to a model file!
% `6 ^9 \6 I: I1 { simple.LoadModel("C:\\Models\\Test.spp");
& O* D2 p) V* `}
4 ]7 g$ m1 r& ^. ?catch (e)
+ [' g4 V$ q2 p0 ~3 [/ ?$ L: ?{ " k. S( C1 l5 t
WScript.Echo("Could not load Model!");
7 n" f* P" d6 D* U WScript.Quit();
0 {4 P( g, n- Z+ _}
% Y( R3 @1 b) X" ]- }7 |' H, }1 v . h: O c% J1 Z! W- B o
try : a l, F& E; X
{ , ~+ x1 q) x: K& n( U
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 7 {5 Y+ ^+ K5 }' t" S o
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
5 c) p& _3 c+ S# C2 o) W% u- h if (r == vbCancel)
% o* X, w$ L4 |, O; p& n. d+ E {
- E" ~6 n6 c0 ~ simple.CloseModel(); ' c+ A0 X G+ ]9 ]
WScript.Quit(); ' x7 D: S4 l+ J M1 y8 m" p( _
} - s' z8 Z1 I0 x: M! Q7 A9 l- y
}
; l6 h! F, M1 s# s# _& e
* Q: \9 `! h8 e8 Nsimple.StartSimulation(".Models.Frame.EventController"); & P$ ^1 B! ]: i- @/ p7 X! U
2 {' g3 B+ v8 ^if (simple.IsSimulationRunning()) 1 t* \2 u$ z. k/ ]# z1 y
WScript.Echo("Simulation is running!"); ' h+ |( B$ q7 T/ S* G% G- n
E! w; H9 \5 y3 m, ?+ k) n// Wait until simulation is finished
|! p: O- {0 Z# K( g- e' w y! Rwhile (!Finished) WScript.Sleep(2000);
% {' g b/ b9 N$ Y; T 4 X% ^! k% S. r# u5 b, ~7 ^
simple.CloseModel(); $ J1 L6 b: H. I' K
simple.Quit();
8 q# q, l$ l$ n) C% T7 |0 vWScript.Quit(); + F# c0 i; I0 U
9 m1 I0 d# E: U) l
- ]" a3 B& M/ p! _2 t1 J9 vfunction RemoteControl_SimulationFinished() 4 E( Y. V- l9 @% `0 i h5 e0 ]
{
4 i. P8 b. W& d1 s" J$ W n WScript.Echo("Simulation Finished!"); |