Example of a JScript 1 k& i6 n9 g8 O. G( y1 ~
var vbOKCancel = 1; - ^& g* r- v ~# f* [8 D
var vbCancel = 2; 9 ], d* d. b* ^
var vbInformation = 64;
4 ]; ^* t$ B8 `var Finished=false; - x4 J# q, c+ N, `9 K" l6 H- |
' E9 H$ _$ u7 o2 |' t( d) n
var WSHShell = new ActiveXObject("WScript.Shell");
m+ s: q9 b3 a' c; z! H
3 j7 f# h1 ?% g- m# m. ivar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ; L* T) F8 Z2 l
& v# M$ e( i. O3 {' P3 @8 I4 J
simple.SetLicenseType("Runtime");
: x2 G6 ]" R, z- h6 d
6 f2 z' k' w0 T* ~, S' jtry
/ }* q! s: u- @! h# A/ F3 a$ _$ u% C{ 2 X8 H# c8 c$ v3 x4 \
// Enter the path to a model file!
+ `2 E: B& T+ x9 u) g5 m# ^7 _ simple.LoadModel("C:\\Models\\Test.spp");
4 m. A$ l. S/ h9 v! J- f7 j9 m: E} # N2 v9 }4 K. a6 O& }
catch (e) 4 L( K1 S+ A& l% V* k( K/ x$ k
{ 0 N0 f3 @* q" ?* r! b8 {& h
WScript.Echo("Could not load Model!");
+ s. X( i% q+ @) E: v WScript.Quit();
( f& ] n5 s- @1 U$ o X9 Y% o} 4 T1 e: Z; X6 [8 L7 O6 c
7 t/ o1 X/ |+ V0 f8 H0 m
try 0 m7 Q$ ~3 e( S8 O7 d# W) z! K2 Y
{
d p! r- \3 Q9 ? simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ' U& v \- s/ t, ~8 Z/ @; [
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 5 x6 c) ~) ~+ c$ H* ?; @
if (r == vbCancel)
9 e! e! n8 t5 K2 w- |+ J- Y7 r {
( h6 F: s) E5 G' T$ T5 n simple.CloseModel();
. Y) j" E& k$ ?9 B/ B WScript.Quit(); + L) B) B: q+ K3 K. j# y2 O
} ! H6 a3 j8 D7 N5 ~3 {! _4 z) W( Y# \. G
} * z9 ~6 Y; T q: B
. |4 }# @8 A' g, ?; i
simple.StartSimulation(".Models.Frame.EventController");
\+ i- ?9 P) i 1 d6 i% b! S! }- ?+ j6 O0 t
if (simple.IsSimulationRunning())
) d5 B, m/ t, b, N2 h WScript.Echo("Simulation is running!"); # y( |- u: E+ t
+ ]0 f3 K* z2 Q: t# z
// Wait until simulation is finished
1 y8 D) g9 f0 S; ^- twhile (!Finished) WScript.Sleep(2000); 9 \7 R: N2 l" }4 }9 m$ {: D' T2 ~
0 |# T1 `% q- s" q4 G
simple.CloseModel();
2 `9 M6 Z$ L( fsimple.Quit();
6 d2 K: v( K- r+ BWScript.Quit();
$ D$ O6 c' S# \+ Q: n. p# ~6 E
1 {. t* [3 m9 J2 y4 F% G
3 @* m6 f+ J' z8 V$ yfunction RemoteControl_SimulationFinished() # w7 i1 ^! l$ h/ Z0 ]& c
{ ' Z @: B1 T, R4 y, q9 ? [
WScript.Echo("Simulation Finished!"); |