Example of a JScript
! K- j" N) H/ X0 k+ d3 Pvar vbOKCancel = 1;
% D0 T& f$ B1 @5 H1 q( Vvar vbCancel = 2;
; ^; Q$ q8 u) U- o) e4 B9 p/ vvar vbInformation = 64; & n& n7 g. X' z- d
var Finished=false;
' ^" o# q$ {5 C! L
2 o% j( j% _, n L" o# Rvar WSHShell = new ActiveXObject("WScript.Shell"); 3 ?5 X1 ] v8 {! y
3 e& x4 w- }& {9 F2 Ovar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
, C* s, J7 `- c2 T : U: P2 K6 o" e. i O, C- `$ z& D
simple.SetLicenseType("Runtime"); $ H- W F7 M6 U( b
" \% n4 {& f- B0 k4 Atry " ^0 N& Y- e# j+ ]! f1 w9 D
{ 3 {/ e( b& ~5 {- ]# ]# }
// Enter the path to a model file! 0 O6 u( T- f* Z8 i; W- \% Q
simple.LoadModel("C:\\Models\\Test.spp");
; x$ Q& h1 @) x} 5 A9 K: C( t/ n" _2 i
catch (e) 8 M. q6 n0 Q/ O ?: f Q( X
{
8 [# c% d- Y5 D% T; C& L8 H; J7 N WScript.Echo("Could not load Model!");
( B+ B. K8 e' N( {( l WScript.Quit(); 9 l# Q, A! y: K9 y, E7 a
} + s. o+ t! H3 S6 G% ]: J2 r2 b) W3 r
6 |* t2 c v. K$ _7 j4 ~try
+ {( K; x& @3 S1 L$ }* J: S{
' Q; S+ a( N1 y N! q simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
- K7 b7 B" E$ H2 E9 r! G9 Z r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( u d' C, O% V& ?7 g
if (r == vbCancel)
2 c' f( Z5 r! w {
$ n( G$ z v S8 D/ } simple.CloseModel(); ) ?/ Q1 R* h9 x, j! `0 ]& p
WScript.Quit(); 3 P. }# C+ {- d0 ~
}
( a6 }' v! Y [9 d% B, V: Q}
2 A# l T8 f' b' i% [% q4 H
( l4 m4 v9 s1 E/ psimple.StartSimulation(".Models.Frame.EventController");
* S2 _" A# y z: O
6 H2 l5 m5 D6 x* Uif (simple.IsSimulationRunning()) ' k, R3 g4 h5 d( C! M' K# Q
WScript.Echo("Simulation is running!");
g+ F! m( C/ L& ]: k3 b % U2 m w c: e
// Wait until simulation is finished 6 Y% J% P. Y0 Q! q1 E. q/ Y
while (!Finished) WScript.Sleep(2000);
& l- D1 F6 @. C" p- L* x. a + L/ h5 b5 f0 E3 I9 y( b6 M
simple.CloseModel(); 5 z; `9 m4 n7 H6 y
simple.Quit(); ; t9 ~, G6 G6 D: B, D
WScript.Quit();
# m7 ~$ ]- z' _ G0 y) w' ]( a8 ^9 ? ! \; t& O: U# M/ k: M) K
, w/ `) \$ k q: f2 G Vfunction RemoteControl_SimulationFinished()
3 a+ f" ~" C$ }: B2 b{
# [* `5 {) y1 {8 y4 n WScript.Echo("Simulation Finished!"); |