Example of a JScript 5 }7 D5 m: k: Z' P
var vbOKCancel = 1;
. Z8 A- H% g& }4 I6 x# a8 Svar vbCancel = 2;
; m/ L/ k$ H+ k4 z, avar vbInformation = 64; 6 B3 o0 O6 y" L$ w
var Finished=false; # k2 a% B+ W5 o* T
1 n8 A# H9 M* m4 h. z H
var WSHShell = new ActiveXObject("WScript.Shell"); , z$ r3 k7 S1 [' a! |% F5 e
1 O1 ?6 \, w0 u ^
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 Z4 r. U, A5 }3 B# j
- `! ~, M' I0 W' O6 {5 |9 a% o6 Rsimple.SetLicenseType("Runtime");
* z6 ^, B! I6 C. r' E e
5 }4 t0 W, [& T$ Y2 k- Gtry ! g1 `7 i) `( g! X
{ 4 ~$ p9 ~+ Q8 ]4 X6 m; F
// Enter the path to a model file!
2 o5 o) L3 {3 |$ U- K! ` simple.LoadModel("C:\\Models\\Test.spp"); 4 O' G# A9 ?: e1 h4 {" H% V
}
4 I. p( I) w. N u; `catch (e)
9 K+ ]% K; ^3 h5 d( H. q{
* Z; m- e8 ~# Z& u) j: e WScript.Echo("Could not load Model!"); & Q" k/ T# |$ K+ D* V
WScript.Quit();
2 L, G! c% f- Z3 h- ?0 d$ a}
/ l1 S: L8 J1 \9 W7 E" X
" L7 a/ o+ _/ L! |. A( y6 Dtry 3 W# D" |2 ~0 A$ j: w6 D
{
! S7 P- ~0 |7 D simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
( B# g# |/ Z7 o8 f: Z$ @7 u4 w r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 {. i! K4 F8 y3 N
if (r == vbCancel)
& {- I. Q# y: y1 H; e1 c {
( W7 @/ A' V- i simple.CloseModel();
4 n; w- B I, s WScript.Quit();
5 w* a5 H5 h1 N }
- ]* C) {, Y" \: |, b3 r4 ^} s6 O0 C# q7 u' A9 v' e0 R% a
4 ]5 y3 z7 v/ ?7 m# U9 Ksimple.StartSimulation(".Models.Frame.EventController"); + f8 R1 g, ^9 `
c( s' s. O8 s! cif (simple.IsSimulationRunning())
$ c9 A5 m, M9 U1 n2 T$ M. r: R# Q0 Q WScript.Echo("Simulation is running!");
; G$ r0 c( W& Z6 N& C7 ]4 V6 F
# b% u) \( ~0 U4 r, ~3 g// Wait until simulation is finished / i- f* E. j; @) Y, }0 g h
while (!Finished) WScript.Sleep(2000);
. c/ [# i) z# T0 I( f) _0 k0 C / B, X( {; E& ]. s% `
simple.CloseModel();
) i9 E9 I( @5 Y* m* c. i9 Vsimple.Quit(); ! J! X3 h. x4 ?( R9 |
WScript.Quit(); 5 S2 n, t \: D) k9 `9 g
, O6 @8 ]3 U+ I ; o' Z! b. x& A+ U( U4 e- \
function RemoteControl_SimulationFinished()
6 K; I" G; @, K- m }- ^: J{ . m% K; H$ U& } V4 O! x6 W( l0 i" T
WScript.Echo("Simulation Finished!"); |