Example of a JScript
- ]! e8 G, r8 u. m1 ^( ivar vbOKCancel = 1; * r7 }& N5 H) T' M* c
var vbCancel = 2;
' @ |# h; e1 O0 r1 dvar vbInformation = 64;
5 I! ^+ D& W- t* W' cvar Finished=false;
% f2 e+ Q* M$ X8 `6 S / X) { `, O* g: w9 F
var WSHShell = new ActiveXObject("WScript.Shell");
/ o: q: {# o$ u6 G ( ], h& ~9 t9 l5 y5 I* e
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
3 ~ F h8 v! w: G" \& u $ d# `/ x! _/ F1 D5 ]
simple.SetLicenseType("Runtime"); + \# j, l! s- Z `$ D3 c3 L
: ^* E7 m0 |7 }2 t0 wtry
0 T7 U- K7 z+ F# B, h/ ~! [0 V9 ?1 ]2 N{
" q* b8 M0 I) c/ h' q // Enter the path to a model file! * K" u% ]* K0 t# P! P
simple.LoadModel("C:\\Models\\Test.spp");
* d# R0 @- k, q7 P- {} & k1 A4 x8 _' b6 Y' ]5 ?
catch (e) 0 ~7 B ^- D$ e1 E
{ k) x& q" X4 ^& e- _+ m) ?
WScript.Echo("Could not load Model!");
6 s* B- ^; v) Z& d# r WScript.Quit();
G/ @/ z+ K: z ?} & ^0 s1 a% n; [5 U. B3 }( k
' T- Z6 H4 L0 H- s7 A* Z ptry , H5 o' V N' k2 W" h
{
- n( q: B# r* s! p& @8 G, @ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ( n4 T$ }- Q2 Z+ z! O0 i
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' P5 d3 V: y; m9 R5 `
if (r == vbCancel) ) o) \9 d2 ^7 V2 M
{
6 k8 n) T( ]1 P8 N5 n simple.CloseModel();
3 z; t9 y! U3 X& d) t& [ WScript.Quit(); L0 T9 S, M* G) }8 f" K5 [& Z
} # S' |* W& C' ~( A0 H4 }$ r
} 9 K) f* Z2 c7 \
3 E1 g8 d: i, G4 O5 N, Nsimple.StartSimulation(".Models.Frame.EventController"); 8 w$ M# o$ }( G8 i
6 a6 m+ P& m* uif (simple.IsSimulationRunning())
3 H# g0 x8 _! k& t6 T2 X% m WScript.Echo("Simulation is running!");
7 t' F& w7 j: p4 F# M9 J# V4 j4 i v# a5 O3 z1 ?0 j( V: Z$ y
// Wait until simulation is finished
4 |( v. n& j, K8 _while (!Finished) WScript.Sleep(2000);
" `2 y5 W: ~: |
5 o8 i3 a _2 |0 @8 H" }' h1 Isimple.CloseModel(); + u1 I8 M1 }- s
simple.Quit();
& d2 ~: n2 r+ A; `3 vWScript.Quit(); ; q# p4 V5 P/ Q+ k
5 c2 `( T( h4 R, m" d
9 x8 _+ F2 @3 ]2 Z. k3 { ofunction RemoteControl_SimulationFinished() 2 r0 W: N/ \( G: y d3 z
{ : C/ }6 K9 X) c; }2 `
WScript.Echo("Simulation Finished!"); |