Example of a JScript ' E* [) e b( l
var vbOKCancel = 1;
+ a) @) r; _( p# n0 I! i0 Nvar vbCancel = 2; 3 _! t. G5 x8 u7 e9 O6 f6 T5 o5 q
var vbInformation = 64;
& r% v( w& |% T& `7 avar Finished=false;
; w3 H: P: @" \: l8 G, O/ t
- x) Y5 L% y( h! j( Qvar WSHShell = new ActiveXObject("WScript.Shell"); . e* G7 x: x# y
) R0 N1 e6 L1 R: ]0 j: @8 R0 j: U
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 7 \& s, V8 w& Q4 \
) U( i% g& c7 D, r* ]
simple.SetLicenseType("Runtime");
4 _% E/ u7 r& i. s/ m
: D+ b. j/ @4 Htry " u( K7 Y3 ?1 @* E4 r
{ 5 @/ d2 A; j5 [% K. Z
// Enter the path to a model file! 5 i- y' X8 C/ l' h' T
simple.LoadModel("C:\\Models\\Test.spp");
* x7 K, A: s# B; M4 s% I( X0 ^} % q* t. n% ]# Y! Q& e# p- I" J
catch (e) & l- U, K, \) |2 }) C4 H1 {
{ + E* M- g/ P% e5 Z. x
WScript.Echo("Could not load Model!"); ( q% j0 |+ j/ h9 t. g; j1 a9 N+ \5 o
WScript.Quit(); ! |2 B* [5 S" `4 \# X
}
! h! E1 t' f2 j3 J9 f
7 r6 m5 ~1 M0 mtry
: ~. ?: T o0 h$ @$ X" e1 c{ 9 x. H3 `0 x( S
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
0 s; h3 p9 m. N, z- u$ _ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
9 s: b% y3 l/ j0 l! m# F8 v( r* q% { if (r == vbCancel) # X9 }8 n( ^2 M: F: U
{ . E- s2 Y* S d& Q. ^2 q7 _! ~
simple.CloseModel();
" V* j3 U8 V E X6 j WScript.Quit(); * b" q8 H. F ]4 r
}
- S% Q' T& |$ N$ Y$ [7 p; s K}
: m5 l, {9 T! k* E- v
8 t4 e( x; P2 x+ a/ hsimple.StartSimulation(".Models.Frame.EventController");
+ u0 c! ~, F8 o4 @
" V0 a- R" n, z( lif (simple.IsSimulationRunning())
/ X: P, w7 V. T9 W: n9 y. p) r WScript.Echo("Simulation is running!");
0 L) z7 B' f! j+ k3 m " B8 b' e }% H" n I$ w+ s
// Wait until simulation is finished
3 p; N( @$ ^; Rwhile (!Finished) WScript.Sleep(2000);
/ i* C$ f# P! u+ J) z, V + O5 \: o1 R' ~# a
simple.CloseModel();
. [) k% W% u. ^0 }) ~1 M- Psimple.Quit(); 1 x" V4 F( E0 z; a* V
WScript.Quit(); ( r- m7 G. t: b5 _
0 B8 z& Q/ m9 u: ~: v
# d( c" d% H$ T+ x* ~& S+ mfunction RemoteControl_SimulationFinished() 4 r3 G% @* D" g& ^& n2 u
{ b7 d9 Q6 l( D6 d1 d
WScript.Echo("Simulation Finished!"); |