Example of a JScript
( n, p8 a, H( r9 c: yvar vbOKCancel = 1;
5 o3 u! K- n$ kvar vbCancel = 2;
, V( Y; r9 j) C. g( hvar vbInformation = 64;
" W- Z: B) n2 H' h& mvar Finished=false;
! r9 x& c: u* ~1 Z: ` [% ] & _+ X5 O( ]" W! L! O; c
var WSHShell = new ActiveXObject("WScript.Shell"); 9 b$ c D! Z; ^9 x
! R6 a+ J9 z3 Qvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 3 {9 y: D: @4 z" P3 a) E* g
0 _) x! r# W) [& |2 \
simple.SetLicenseType("Runtime"); - b( N3 H& L3 w* k6 O
# v* ?# i) O! ]: ~7 N
try
/ r5 R; f) C j# g" |{ 9 V; q& T5 S3 n3 H! z3 _
// Enter the path to a model file! $ X' d5 K6 }( C) W g: N$ F3 a
simple.LoadModel("C:\\Models\\Test.spp"); , q, G# a* R/ ^2 H
}
* H& [5 y9 a1 r( S7 n; X mcatch (e) # g! h, h- Z" f6 e
{ # j, [3 ~% \6 j* P6 I
WScript.Echo("Could not load Model!"); 4 Y: Y$ G8 i' Y; J0 Z: Y! k
WScript.Quit();
% i/ E8 }5 ?/ e. R" B} + {" R: U4 T C1 ]; h0 h4 \
5 T) S' {+ t7 ^3 p+ ^try
; e% H4 K: u$ b' w' E0 m y{
+ S$ ^& g2 v. O6 \ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { / i* y" Q: i5 |% }/ K6 U P0 z
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
4 A6 H/ P3 [( `- W. ~$ N$ c& R if (r == vbCancel)
. `. S5 P& u8 O4 e {
, m w4 j9 f7 v( l7 \; V simple.CloseModel(); ; w& E: h; [* f8 K7 D5 i( n
WScript.Quit();
6 l+ ^& c7 s8 N9 r5 n5 p! q }
5 i3 B" [$ i+ |4 K |3 v} , W# w7 Z+ h/ Q/ Y) P
1 @) L2 Y& K# N% r
simple.StartSimulation(".Models.Frame.EventController");
/ Q8 v) O) a1 T) M* Q/ H: { 7 K6 z; U t4 F& l/ u" r, l
if (simple.IsSimulationRunning())
# o% n# T0 h& `5 u/ v WScript.Echo("Simulation is running!"); 1 j, C. m( l7 ~- n1 T) Z4 I P
# ?3 O. n: C; p( E1 w" T( e
// Wait until simulation is finished
4 p9 ?. p+ |, @8 `0 x7 owhile (!Finished) WScript.Sleep(2000); 9 n- X9 f* t0 t: G
% F7 C |( Z" T- B2 Q" q' R4 a/ D8 ~% b5 ssimple.CloseModel(); . ` f4 h6 s9 e8 t1 ]
simple.Quit(); 5 \/ R0 i" F9 S% r* T' t8 j
WScript.Quit(); - N, H& G! J A4 C/ A
6 l$ S; l b! I7 ~7 R4 f
( m$ |9 c5 |3 f% b2 T8 }3 afunction RemoteControl_SimulationFinished()
3 e+ P' \+ r: y/ p; ?2 J3 N2 Z! E{
& J. D: R$ F$ ?! @7 x% p4 g/ y" K WScript.Echo("Simulation Finished!"); |