Example of a JScript
0 ~) |' f* G( {' B2 Y% R% T% q( Mvar vbOKCancel = 1;
4 C6 ^) ~& |% Q9 O2 `; j, [var vbCancel = 2; 0 x, h) n9 @1 ? I+ b+ ]
var vbInformation = 64; 5 s$ u, I1 q, ]
var Finished=false;
1 w: n2 U! @5 r8 a ; o* I! ^. {! u3 q+ g
var WSHShell = new ActiveXObject("WScript.Shell"); ! I! B. _( M$ h
0 O: T9 `$ ]! x& J# C, tvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); : n% u; S* f* w7 E- c
7 E ^2 { i$ i* a$ bsimple.SetLicenseType("Runtime"); 4 _# @, O8 `& _* F* [3 V& [* a) I
7 Z& }9 g& a4 J K* L+ Mtry
* ]( k# B! F# O" n- |{ % E$ ]( U* J6 d3 s6 M6 N) {- Z
// Enter the path to a model file! 7 Y# e/ q8 i7 v
simple.LoadModel("C:\\Models\\Test.spp");
* Y. D0 d# Y' N} 8 p" ]6 [! p. M, r% \8 v, K% `
catch (e)
! B) G6 S* ]. V9 q) }) M{ ; t7 d; s( Y6 G
WScript.Echo("Could not load Model!"); ) p' x7 \* Q' |! ?
WScript.Quit(); i) G5 Q( O1 _+ n& w
}
* [7 A% I8 g" {
: G' w9 L! C7 Q8 t, n5 ltry # k. c9 o' i2 g2 U. X
{ , V f% i. h5 }3 \9 ^$ {2 V8 M2 U! U$ u
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 N& a: w% W4 c' B+ }2 B r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
" }' R% `- |* m if (r == vbCancel)
{: \4 Q( U1 g8 M { " Q- A. Y* j% _" {2 X9 Y9 |0 F
simple.CloseModel();
. o+ J, [ Z5 g& P+ C @( Q WScript.Quit(); 1 g7 i4 J, p- E; Q
}
8 _" X( |$ T) n1 G' c( f7 p} ' b$ T3 l/ A' \, b0 z
; [( W( a7 _- g- X" ~* ]: g1 Dsimple.StartSimulation(".Models.Frame.EventController");
9 _" S+ \. d% M$ a; }/ A # P6 J5 h8 M# t7 G {! G; @- l: G
if (simple.IsSimulationRunning())
* p# ] ?4 c) f% a% o WScript.Echo("Simulation is running!");
7 H/ K( p4 \; }
* |+ g o: `% T// Wait until simulation is finished
7 d4 R2 M. o$ R5 s& X( O8 z. [/ Fwhile (!Finished) WScript.Sleep(2000); ( W( @& t2 j, {( y; P4 X
m! M* l" S* s2 s$ R7 ]6 Psimple.CloseModel(); % F" M- X2 V) j. d1 U
simple.Quit(); 9 v3 X* f7 G5 c4 T: u
WScript.Quit(); ' ^: b( S5 _6 B
6 |0 P0 a! ~! M" ^; o, ~% [
5 F- q1 A/ l( K4 [% L7 c
function RemoteControl_SimulationFinished() z5 Z4 l7 U/ E2 s0 U# ^
{
7 x) `$ |7 P% V9 z) N# A WScript.Echo("Simulation Finished!"); |