Example of a JScript 1 a( R6 Q5 C" E# |. D1 h- z7 g1 {
var vbOKCancel = 1; $ I( ]8 }# H" Z( o
var vbCancel = 2;
' G# g( O8 Z" @4 G( [var vbInformation = 64; " ~# z$ n- f! S+ K: @& t7 @3 J, }# T
var Finished=false; " u4 o2 \- I+ [: ]4 n0 N
Q6 ^8 H+ ?/ X. lvar WSHShell = new ActiveXObject("WScript.Shell"); 6 R# s5 i; |: m$ Y, R
" k% X5 x, Q& K
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); : ?& ~/ ^! n2 Q
) j# I+ `2 O+ |/ fsimple.SetLicenseType("Runtime");
6 {5 q& s3 w5 t9 j. m Z 3 `; b1 X/ Z- Y1 M
try 7 ?5 P5 L0 Q1 L- ^
{
& T/ O/ d2 r9 e7 [4 c" B // Enter the path to a model file!
) C( B6 T6 x* K' K simple.LoadModel("C:\\Models\\Test.spp"); 7 \2 _4 m( I: J3 }" B& E
} 2 l# I5 g( P0 d* G! \
catch (e)
2 t) M$ j& Z3 f4 y{ ; p# q5 [0 o' F) D! L( L
WScript.Echo("Could not load Model!"); $ l; h& p" F0 g8 W4 I% z
WScript.Quit();
: b) r k. z0 }3 I2 ?2 e6 a, y} f( T8 l7 G/ z1 p6 g' ^
" C& \2 Z* b/ k0 Q- Z: Btry 4 O7 W) N7 x: [
{ 0 x0 A' P6 Y$ y+ M# b2 n
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
+ Y, y4 h7 C$ o+ a+ F7 c r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); $ l- N' V0 ~. m% q
if (r == vbCancel)
% d, \7 |& u# g# x { ' K5 q! C5 }# k1 g) P# O
simple.CloseModel(); 7 P; Z# y; R3 x9 j ]
WScript.Quit(); 1 E+ _; i% l( o" h! {7 W4 ?9 ~
} 1 x# g* D' B, i; l
} % c$ Z" h6 U x' J8 a3 W
$ I2 ^1 n, Y2 V6 ?7 R, V
simple.StartSimulation(".Models.Frame.EventController"); 9 d) I* n7 H4 ^# ~$ S
" i+ v7 v# g. Z, o
if (simple.IsSimulationRunning()) ' D& Y& d! C. Z: {* g
WScript.Echo("Simulation is running!"); & K8 H& b* I7 _: W7 S
2 |( ~# N9 s: N# f4 ?8 f) a
// Wait until simulation is finished ) Z; n# B; t* c' J% _2 z- |/ X3 s
while (!Finished) WScript.Sleep(2000); ' ]$ _' }$ |# P R1 I
J& }# n1 ]( ]3 H8 {8 W0 ~simple.CloseModel(); 8 n/ A* Y' }) s: a# W! W0 J* u+ u+ m
simple.Quit();
9 \* o g. r! ]WScript.Quit();
3 N4 U( B0 O' V6 i; q M 5 r# l" r+ n0 K! p
9 k" J9 h' I% ]) t9 Q% ufunction RemoteControl_SimulationFinished() ( j# z1 K- U( T8 C( L& l, C( H
{
+ }. `& J% ?' n. p- y2 V WScript.Echo("Simulation Finished!"); |