Example of a JScript 4 D, D8 K! M; `# D# l
var vbOKCancel = 1;
# E! }% m. g' H" pvar vbCancel = 2;
5 H' K Z/ @% rvar vbInformation = 64;
# p7 ?3 m# l6 G- `5 A( Z cvar Finished=false; 1 s3 d, n; c7 J# A! W8 R
* T9 f" l" C+ w- Y7 a
var WSHShell = new ActiveXObject("WScript.Shell"); * s4 o: |; B6 |3 c* W0 ?
0 A, p2 G! ?+ L1 D' [6 ~
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 4 t, e p& w2 ?, f5 K+ }
! d( e2 w1 g/ \
simple.SetLicenseType("Runtime"); u, g" `6 a0 f- x: {: [ o
) r" t8 K- m1 E! P" \: ^7 c* W
try
. G( s- C) p4 K8 s" w0 Y1 D{
' I2 {) P a- ^0 m0 _1 O // Enter the path to a model file!
9 O& y& j* b6 H( c4 ? simple.LoadModel("C:\\Models\\Test.spp");
% ?% |1 B0 B! n& u" F* z( a3 l S}
7 d2 x$ t3 U* O5 Scatch (e)
9 H1 H0 M: ]4 L0 C/ k6 O& z{
9 s' g+ f7 q% j. a& Z WScript.Echo("Could not load Model!"); 5 }4 h7 c# b/ N, ~* e
WScript.Quit(); : V1 i) g* m3 ~! n
}
; I! @0 V6 U u
( s9 W1 m! y% y6 ?. a- e& g6 O" Btry , U- A+ n3 D$ Z
{
& Y- j7 \) e# M8 M# [ f( [ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ) _8 Q6 V: y% v" c& V# A. g! H
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
$ e3 I% ^) J& k" p3 t2 C% p0 S if (r == vbCancel)
/ P' I8 m8 e" _# E4 L- o7 B { 9 i8 o3 J% R3 }% x: M7 b3 l9 E; A/ G
simple.CloseModel(); # o5 q [% p0 _. S
WScript.Quit(); 0 V# c- K5 J1 a( _! m+ X3 N
}
1 x& x( K) q& v7 _( Y} 5 j7 f3 i7 h5 U- f v1 ]
. s w$ ^8 ^. E' a: Ysimple.StartSimulation(".Models.Frame.EventController");
$ I: e& B' t; } 6 z# V8 u* _. y$ S
if (simple.IsSimulationRunning())
4 i! w$ W% X% d5 |& Q8 q WScript.Echo("Simulation is running!"); 8 C+ w, V5 l" Z9 Z$ y
% H- u; L* a( l// Wait until simulation is finished
2 f' I! G" p: ^% Xwhile (!Finished) WScript.Sleep(2000); 2 S3 Z ~+ d+ h
2 k& _/ O9 n4 V [
simple.CloseModel(); - |: Q8 C" d8 A
simple.Quit();
' \' o2 A' |2 s: R9 ]0 GWScript.Quit(); 8 ~1 |" q( X: g8 s8 H# [' q# e
: T. @0 _6 x9 ]% Z+ N
8 g% i! j* L5 r5 p0 z( i8 d: A( \9 @) O: dfunction RemoteControl_SimulationFinished() " s5 W% P$ y. ~5 i6 k6 Z6 _1 v3 \0 l
{
9 [+ w5 e/ F0 G2 |. a WScript.Echo("Simulation Finished!"); |