Example of a JScript # s# s4 U3 d% K9 @0 ?) B
var vbOKCancel = 1; 5 g- O2 i) }) l
var vbCancel = 2;
* G g: T, E9 \% ?var vbInformation = 64; $ P9 s5 K" P: g) Q3 n
var Finished=false; m3 j' ]) K: I2 r% `
6 |$ ?! y% @8 F+ A) `5 u
var WSHShell = new ActiveXObject("WScript.Shell");
" J/ r7 l/ c B6 i9 C, J' x& R5 c ' p/ @" \4 C$ Q5 X3 i6 p* I
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 ?% Z, }/ ?) `- n( i
/ \8 p1 g% l, S. V9 R4 E+ h
simple.SetLicenseType("Runtime");
* b7 D* ?0 C5 ^, d+ r' R+ P
" F3 J& I& |( X1 D* t! e7 y0 p Ltry 1 {* Q. H# M. R
{ ! R/ n& Z1 a% L8 _' q
// Enter the path to a model file!
7 `1 n) l5 `9 U- M6 }- J simple.LoadModel("C:\\Models\\Test.spp"); / t% l' p) u4 L" D# w+ u
}
5 ~3 C! {' L }+ [. A! ]/ Ycatch (e)
- B7 v" Y8 Q5 h( H{ 7 k5 D: w+ n4 k2 H" `
WScript.Echo("Could not load Model!"); + w% W0 E. _: q; U
WScript.Quit();
& w4 P6 E$ n9 l. }. s} 0 Q8 m+ Z+ A- @9 }
) L0 f y0 C- T( u
try 3 |' U; C0 D N U/ c( v/ C) \
{ 9 j' [, _! F& j
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { $ ]$ ?# i$ y: W
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
- H( A" C2 }% d) _6 J; a$ B' M7 n if (r == vbCancel)
4 A B) i" _) j5 V, Z: ~ { 9 s* u; ~; k2 I0 a9 ]
simple.CloseModel();
7 J& v. g! `* b, w WScript.Quit();
8 `- ]$ d& }0 }0 F! Q2 u1 j3 { } $ \$ h @/ H6 W
} * m/ e( F1 j7 T* p
: k9 F! `! J4 i9 {6 J1 ]) t. Wsimple.StartSimulation(".Models.Frame.EventController"); $ n$ a f. d' v2 G7 a8 |$ R
+ G3 J5 n% Z* B4 u: x3 j( Hif (simple.IsSimulationRunning()) 2 T* E6 |% R) J4 o m
WScript.Echo("Simulation is running!");
" {& m J7 E2 B+ p. z3 t* Y 8 X9 _$ y% l& D# @, _9 ]$ ?( Q8 X: s
// Wait until simulation is finished
4 L% o0 z2 j) t5 O" Mwhile (!Finished) WScript.Sleep(2000); 8 b; K$ \# E; L: O* f
1 b' w# i( J: Y& t- v8 g9 N
simple.CloseModel(); % u6 q/ e2 G; q, F9 \1 Z
simple.Quit();
8 a' u7 B f6 {; e9 aWScript.Quit(); 0 W& D6 |1 y7 Z# i: r* _7 J
( Y2 u* C v7 J5 [. H7 U- K
' V/ @- V2 P4 Dfunction RemoteControl_SimulationFinished()
3 I0 ?! {) `" c: R9 K' @% I1 ]{ , R! _( D; r$ ~/ P# d' \' _
WScript.Echo("Simulation Finished!"); |