Example of a JScript ! O2 r" q7 M' L9 l
var vbOKCancel = 1;
3 a: _( F1 g% Svar vbCancel = 2;
* P* d0 t- D% c, |var vbInformation = 64;
1 }) W0 g; i; ^7 Fvar Finished=false; $ g' l' ~! _- \+ Z) I% D3 m# m
5 H' W8 ?$ M( Y3 K$ L$ u
var WSHShell = new ActiveXObject("WScript.Shell"); ; E; W' {5 c3 G6 t4 [
4 v0 G( @+ ?8 r+ P1 B- {( ?var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 g* G8 _& \ N 3 {& D/ b, C, @+ Y/ f
simple.SetLicenseType("Runtime"); . k, K9 D8 B/ c+ _
5 p& z5 P. d8 O p# c9 J f9 j
try
) u+ e) r* _) G# `{ : h; i4 R, A& ~' v
// Enter the path to a model file! ; w# {8 h3 |1 }# t C' |" Z
simple.LoadModel("C:\\Models\\Test.spp");
6 n8 Q8 P' l/ J. l3 I& t} , s u, t9 k' w4 g. p6 c3 S2 Q
catch (e) ! q; R) {0 Z0 i) f0 P% l8 l' l
{ + d$ x! T% S( N) F! \
WScript.Echo("Could not load Model!"); # {+ W, `, r* [, e6 J6 V
WScript.Quit();
# t; e8 L( C n, x0 ~- S}
* l7 M( H: p5 C! P) M; f! C2 _
5 }- J* x( j$ k; F6 H) ]try
; t& E& o5 D( [2 T. x4 j, u9 c7 |{ ) V; j# n( {$ E( h. k( W) \
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
$ M0 |0 w* B. z3 Y5 u r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( I# v8 ]; s3 K
if (r == vbCancel)
4 Y% i9 x- `/ ^: T" A( ] { % {, d4 u4 i+ y' y# C9 ?
simple.CloseModel(); # {$ n: E; g2 u7 F. Z F; x, J- ^8 v
WScript.Quit(); 0 _; i: h7 c$ X) _7 J6 G3 [# S- Z
} 9 k! F1 w7 O; |
} ( T3 B H# [/ O
) V8 s8 G) f# l7 o3 t
simple.StartSimulation(".Models.Frame.EventController");
2 u. b8 j% s U- E1 X, S \9 B 5 f. f+ c8 c/ [0 E( J4 T
if (simple.IsSimulationRunning())
+ Y. Q% E" q( ]! ^ s WScript.Echo("Simulation is running!");
- e1 N) D; H/ i# R ' {/ A6 U# {$ {5 `
// Wait until simulation is finished ) b8 U6 `& S# ]& @9 d2 F
while (!Finished) WScript.Sleep(2000); 6 S0 {1 \2 Y- W& G8 C1 N
. `: t! @1 [6 k) @4 bsimple.CloseModel(); $ o ^9 u* Q- X3 S
simple.Quit(); 1 v9 \9 S! n8 }$ d5 `
WScript.Quit(); , Y/ p; Q- Q% o6 C* S# K5 F3 n
. ^4 B4 ]! V( R
' R+ D1 [( Z* `# nfunction RemoteControl_SimulationFinished() 4 s" x5 C8 {, H2 j" y0 s; D! z
{
7 t9 e# \) L- C; V8 y9 P) H6 l WScript.Echo("Simulation Finished!"); |