Example of a JScript * Y! [! s5 m# C$ X* x
var vbOKCancel = 1;
# z N; t" P7 u$ G& vvar vbCancel = 2;
) ?4 B0 {" v6 s! @& M' Jvar vbInformation = 64; ( g9 S8 S9 Q( |0 p8 H+ i; Z
var Finished=false; / H( x! G* h$ ^( O% `; R
5 B- S( u8 N' c5 D
var WSHShell = new ActiveXObject("WScript.Shell"); . @7 z; Z# ?% B! ^
8 K, a$ e4 C9 s! \- x: \6 e+ D8 wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 3 P& H* m5 [' l: ?5 X7 h
2 ^; t: `# M- O- C$ {
simple.SetLicenseType("Runtime");
8 y2 t' Y0 I% L
6 M& R$ r9 \0 T; Q7 mtry " R9 K+ B$ y0 p# _, v
{
: |8 b5 f* @* p( r // Enter the path to a model file!
+ \4 n& r7 m5 _ simple.LoadModel("C:\\Models\\Test.spp"); & U: F/ p- M; O9 R5 V
}
3 P- L5 Q* ?# g- Xcatch (e)
* m+ }1 m `8 S2 A* o& V `{ 0 q }, [" @+ V; F
WScript.Echo("Could not load Model!");
3 g8 ^& d% c; E {* o! x. j* ^ WScript.Quit(); : A3 q& L \2 R: D$ ~
} 6 v3 V8 d t. N) ?
* q" h( O" {$ B$ E4 Y0 z
try + g. n6 |; l# K9 T+ j# v, J7 m
{
$ e8 q( ]6 W* d! F% Q simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 4 s) T* ^; I- v8 @1 I
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
8 o) }# c. N. G3 { if (r == vbCancel) 2 B% |% c, C+ y3 |+ B' ^1 \( v
{ 6 W; l4 [* j8 Z" n- O& u+ D8 V
simple.CloseModel(); 9 g: \( K( l, y& y; q
WScript.Quit();
1 V" T% x( U5 Y2 c } : e; J; C" C8 T' C
} 4 q# \2 o. t& Z: { C! y
3 S @# y: @% C7 y3 o! Nsimple.StartSimulation(".Models.Frame.EventController");
1 e+ N9 h; P! J$ p 7 k, R |% Z0 c' ^' |6 A" O
if (simple.IsSimulationRunning()) * w2 @9 q( T4 z3 x! O% w
WScript.Echo("Simulation is running!"); 3 b+ P. [ E* v8 d1 W, `
6 {' _% j/ _" ?
// Wait until simulation is finished `" B! \# u. f' x$ o
while (!Finished) WScript.Sleep(2000); % X# q8 p7 z' ^; j e2 v/ c
: L& ^0 s2 K& [9 M& U2 q
simple.CloseModel();
1 V- O% T, H( wsimple.Quit(); / s7 W! z& u" s* o- W
WScript.Quit(); 6 }6 v% l' ^/ ]8 \( y
; l$ L# R# c( z
2 v+ Q2 G! v8 _+ P# k0 s* Afunction RemoteControl_SimulationFinished()
0 N! M) d. M( i7 A3 x. Y8 b: b{ + q& \# B' r! c2 J
WScript.Echo("Simulation Finished!"); |