Example of a JScript
; W# h" R/ P* z# {* {& n! n# L2 Cvar vbOKCancel = 1; ' C+ I& f- V) A7 x
var vbCancel = 2; ; E4 ~: o% S! E
var vbInformation = 64;
2 k4 W# N2 m. w6 Y/ d2 |' s- Ivar Finished=false; % Y( x" F5 U+ J1 |2 n) T
h' o5 u2 \( Lvar WSHShell = new ActiveXObject("WScript.Shell");
, V+ _% P( Q1 v" Q' O8 ^* z 0 L; h# R( Q( V' J3 E1 L0 r
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
9 Q$ } o, s2 V; ^) E* S" b+ f1 J6 D ! r- ]- K/ j1 ]; F0 }
simple.SetLicenseType("Runtime"); ; z+ R; t' s. R' G
- C* c) h4 l$ gtry % J. l; G1 w* f0 ^
{ 6 L+ l% M9 q+ M a) J% `
// Enter the path to a model file! 5 `+ l& g3 D/ N/ T1 J& @
simple.LoadModel("C:\\Models\\Test.spp"); - \: q7 q1 l0 m6 ~: s. |
} ( b( n. r3 ]" N
catch (e)
. O; V0 T- v4 @{
3 H2 T- @9 } _2 t! b+ T! j WScript.Echo("Could not load Model!"); * A. J: a4 z$ O3 J! i, |
WScript.Quit(); ) U; J) l0 s5 |% L( ^+ i8 S8 y0 g
}
4 O1 n& N: @1 [% s
0 x, l0 l4 b, K! Qtry
' X$ q# a9 g& q6 y6 G{
0 ^ f+ N E3 _' f6 O simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
5 S, C7 t7 U! w% d! W7 ` r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
- O" L" ]% K: c; _# z" O/ I if (r == vbCancel) 2 [- [5 Y, I+ n# m
{ ) g3 [0 t2 Q0 h5 k# l
simple.CloseModel(); " k$ Q1 W5 Q3 N
WScript.Quit();
; p! r1 J- M: b: j' Z# J2 n9 ` } 4 q& R& f/ q2 c' L) A
}
B. N! Z3 U6 T
0 q8 ]* D {+ A6 z; y8 A: Xsimple.StartSimulation(".Models.Frame.EventController");
, d+ y5 Y5 r% p$ W- Y1 ~6 o+ `
1 v) }' x2 E- U" Q1 @4 U1 R5 m# y/ Fif (simple.IsSimulationRunning())
; Y8 x( U3 O0 {3 [6 M; ^ P; I8 I WScript.Echo("Simulation is running!"); 1 M4 v6 w9 C0 M% x) c* j1 g" l
- m. q# I. p7 |! K1 ?% U* Y// Wait until simulation is finished
6 p6 d3 i- R) q+ C% y' lwhile (!Finished) WScript.Sleep(2000);
( j% N# B, E# h( ]: A 3 _( Y0 x* @5 J" G
simple.CloseModel(); 9 q2 c7 m$ q$ y1 a7 q$ q) K
simple.Quit(); ! V* i9 Q" h% q
WScript.Quit();
6 W Q9 n x; U; D$ G+ o5 n 9 Q9 Q, F/ b2 A7 m3 `5 j4 {
( i( U4 y+ X8 l+ b; j
function RemoteControl_SimulationFinished()
K6 Z$ W: r- O4 z: y{
9 q! j0 U" w0 E3 u" J WScript.Echo("Simulation Finished!"); |