Example of a JScript
- C) W9 K: a0 N p/ x- W/ jvar vbOKCancel = 1; 7 `8 S9 z. l2 u0 B
var vbCancel = 2; ; @+ {3 }7 S# h! m* A
var vbInformation = 64;
" `( M) C" l3 U( n6 bvar Finished=false;
' W9 r" o7 C) f" f) M " [! {2 F3 w& B8 w. S
var WSHShell = new ActiveXObject("WScript.Shell"); 4 y4 u3 V9 r. U. f5 U$ ?# O
, {) N; c+ ^' C7 T
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 `: m; p6 P+ @1 T: U% V0 w
" O3 ~% V$ T5 y8 [ Msimple.SetLicenseType("Runtime"); . G/ P! K& O# v. V0 y, r+ J8 h
3 R& s. N& t M
try
6 |; q6 T, `6 `5 o; {1 E' Y9 }( l. C{ " z' v8 \: s# F! F4 R# A
// Enter the path to a model file! $ @, i" z. o- c2 R/ E
simple.LoadModel("C:\\Models\\Test.spp"); # M4 Z" m; @% u; _# ^4 ?" o: n
} - I$ q4 j& F( ~# ?3 v) h
catch (e) , J- w. y9 B; g' Y5 ?# V
{ % X! {% H8 V3 x. u9 O
WScript.Echo("Could not load Model!"); 6 M! ^& a& x) t3 @9 I3 ~4 ?
WScript.Quit();
( |4 e* p/ R+ [* p! p: p2 n) V} & V, B) O. V% s" l
s/ l# @; U+ x3 i* e# y* u/ r
try
5 |8 ~1 R( [2 k% p8 f{
2 M5 {$ f& r! s& g simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ' S7 K/ A- J) h5 t+ A6 k4 @
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 H3 S* x& T6 G, y* d
if (r == vbCancel) 1 _8 v0 I, I) k; Z% v- e# I
{ g3 _9 k2 `/ r* b3 h
simple.CloseModel(); 8 ^ g+ f, T, T" J8 m# S* M0 r
WScript.Quit();
6 j/ Z/ f. s' L7 D3 F }
4 T! u$ g, o. {1 }) h} 6 G b6 Y# I3 i- E2 I$ J
1 V$ V& ?! z9 isimple.StartSimulation(".Models.Frame.EventController"); . n& Y/ k3 s! E9 m7 m) Y
) E$ ^% i l* ]6 F1 K; h% e
if (simple.IsSimulationRunning()) # Q! v: U: D/ ?0 w$ u
WScript.Echo("Simulation is running!");
/ I |4 j+ l: w5 Z7 K, [ ( Y3 L5 |1 Q) r% X+ X. f5 w
// Wait until simulation is finished
/ K# W1 S8 O2 b- w+ q( T# fwhile (!Finished) WScript.Sleep(2000);
- p3 d5 Q9 Y8 e% z& w ( \0 F9 s" B1 b. C
simple.CloseModel(); : y; @6 U/ q6 M
simple.Quit(); 8 ?/ o% `8 y0 O* e; ^8 U
WScript.Quit(); t; k0 X% k$ i7 i7 ?% q
" s) D1 v" f" i$ Y& b) g# C# F3 J5 d 6 g, W( A) J' p3 c4 M1 g+ n8 T# N& ^
function RemoteControl_SimulationFinished()
. V9 R7 r& T* O7 E{
) i+ s) b% }( z WScript.Echo("Simulation Finished!"); |