Example of a JScript
6 a7 F% r. R5 T( J+ [var vbOKCancel = 1; 3 w$ }- Z! J% x9 g5 |- V1 P _
var vbCancel = 2;
/ t/ k) M* S5 _6 ivar vbInformation = 64; - ~' z- {8 @" U, O0 A: D
var Finished=false; ) ~+ V8 M9 R5 E( A9 c3 y: [3 c
/ b3 S' I( t6 J& j* ~8 y. jvar WSHShell = new ActiveXObject("WScript.Shell");
9 e" @8 ~+ c, z Z8 D % \5 x$ p* M1 L1 L
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
& [5 b+ _1 N) m# h7 E; u
$ R* Y% Z9 k: y. s' ]simple.SetLicenseType("Runtime");
# c, v [2 P2 @; ^; [; e1 b " \0 e# N2 H; `* u! c
try
9 h7 g0 X7 T: A4 \; b7 ~2 J& \" k{ : E" Q9 ~9 ^$ A$ W; X$ f- I
// Enter the path to a model file!
3 ]& w2 _" Z+ c simple.LoadModel("C:\\Models\\Test.spp"); 7 D+ P6 y/ y. D6 ^
} z9 ?* a% _! _
catch (e)
7 c7 S0 s" `6 q0 k{ 1 C5 ^3 B+ r* v
WScript.Echo("Could not load Model!");
b5 j3 f+ z0 a* G! p WScript.Quit(); ; r. C1 x8 c- v0 {9 r
} 0 n3 v7 j) @1 X0 D( r% J
8 _: {. j: h1 \0 P
try
+ p# K7 w. V. S1 X1 D8 G1 \{ 6 D. z: x# x. _% t
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
! Q8 o0 w } U P1 H r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
$ |# t" B/ g3 X1 j, R8 ?: c! u0 g if (r == vbCancel)
* V7 P; I# B' Y; E { ! k# P( D" u `; w) \: c: P
simple.CloseModel(); 9 _( |- Y2 L6 r( H; h
WScript.Quit(); ) H, Q) G3 x7 l/ Q
}
9 K, A4 L4 [" M7 N( G- `. A} , J, K8 s. Y4 F/ l2 P
) A5 U; A8 j+ s2 y' x2 p; Bsimple.StartSimulation(".Models.Frame.EventController"); - Y9 O# ?7 X( M# f1 o0 I) B' e, n! V
$ O6 ~, F" N- V5 h4 @( y
if (simple.IsSimulationRunning()) 5 T+ S: ?1 n/ u' _
WScript.Echo("Simulation is running!"); C6 U( a! _% Q! y q% B
/ ?3 n' v3 B \// Wait until simulation is finished
6 H0 a) N5 g% ]# [) K! B6 g: f; S- |while (!Finished) WScript.Sleep(2000); 1 O: K# r4 w: X; F
; p, W: V- r3 ?8 a5 L# i) x% |
simple.CloseModel(); 6 j# g: A e8 d9 {
simple.Quit(); : c5 e1 J$ r) _- c; T; G( ^ a5 F
WScript.Quit(); ( ? p+ j# | b* ]9 j) ?
1 h- j Z( H" U8 q( H' F
/ X. T1 t6 U" F: l; b, Q4 Mfunction RemoteControl_SimulationFinished()
+ q1 b- [- Y; p2 {! p{
) T& R" y" \; Y% \* p( q) P- j WScript.Echo("Simulation Finished!"); |